添加一个使用多个Camera 来渲染的简单demo

This commit is contained in:
leo
2020-08-09 10:59:17 +08:00
parent 0f2b38c956
commit a13232387c
13 changed files with 36047 additions and 0 deletions

53
CameraDemo/.gitignore vendored Normal file
View File

@@ -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/

31
CameraDemo/README.md Normal file
View File

@@ -0,0 +1,31 @@
### Camera参数分析
### Depth
用于使用多个Camera时通过设置Depth来决定摄像机的渲染顺序值越大则摄像机越晚被渲染渲染在前
### cullingMask
将决定这个摄像机用来渲染场景的哪些部分。在 属性检查器 中的摄像机组件中的 cullingMask 会列出当前可以选择的 mask 选项。
通过选择需要渲染组。如:这个摄像机只用来渲染游戏中的 UI 部分,一般游戏中的 UI 部分都是不需要移动的,而游戏节点可能会往屏幕外移动,这时需要另外的一个摄像机去跟随这个游戏节点
用户可以通过编辑器菜单栏中的 项目 -> 项目设置 -> 分组管理 来添加或者更改分组,这些分组即是对应的 mask。
### clearFlags
指定渲染摄像机时需要做的清除操作
说明下
COLOR :如果有多个Camera时。如果都勾选该字段会出现把其他Camera渲染的画面都清除掉。只留下其中一个。所以一般只选择一个Camera勾选该字段,其他Camera不勾选。
### rect
决定摄像机绘制在屏幕上的哪个区域,便于实现类似小地图那样的 Viewport值为 01
### 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

View File

@@ -0,0 +1,12 @@
{
"ver": "1.1.2",
"uuid": "a529f388-70d1-4a1b-9cdf-ccad2c8d9e16",
"isBundle": false,
"bundleName": "",
"priority": 1,
"compressionType": {},
"optimizeHotUpdate": {},
"inlineSpriteFrames": {},
"isRemoteBundle": {},
"subMetas": {}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,7 @@
{
"ver": "1.2.7",
"uuid": "77266bc1-4497-473b-b59c-045f432b9150",
"asyncLoadAssets": false,
"autoReleaseAssets": true,
"subMetas": {}
}

Binary file not shown.

View File

@@ -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": {}
}
}
}

32244
CameraDemo/creator.d.ts vendored Normal file

File diff suppressed because it is too large Load Diff

15
CameraDemo/jsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"experimentalDecorators": true
},
"exclude": [
"node_modules",
".vscode",
"library",
"local",
"settings",
"temp"
]
}

8
CameraDemo/project.json Normal file
View File

@@ -0,0 +1,8 @@
{
"engine": "cocos-creator-js",
"packages": "packages",
"name": "CameraDemo",
"id": "3f30aaba-94b8-402b-af70-7bfce0af6cd5",
"version": "2.4.0",
"isNew": false
}

View File

@@ -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
}
}
}

View File

@@ -0,0 +1,6 @@
{
"game": {
"name": "未知游戏",
"appid": "UNKNOW"
}
}

19
CameraDemo/tsconfig.json Normal file
View File

@@ -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"
]
}