cocos2d-cli 1.2.1 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/{cocos-cli.js → cocos2d-cli.js} +17 -12
- package/package.json +3 -3
- package/src/commands/add-component.js +23 -54
- package/src/commands/add.js +31 -114
- package/src/commands/build.js +1 -1
- package/src/commands/create-scene.js +93 -467
- package/src/commands/get.js +5 -154
- package/src/commands/prefab-create.js +107 -379
- package/src/commands/remove.js +123 -59
- package/src/commands/set.js +12 -245
- package/src/commands/tree.js +4 -3
- package/src/lib/components/button.js +137 -0
- package/src/lib/components/camera.js +107 -0
- package/src/lib/components/canvas.js +89 -0
- package/src/lib/components/index.js +157 -0
- package/src/lib/components/label.js +120 -0
- package/src/lib/components/layout.js +110 -0
- package/src/lib/components/particle-system.js +160 -0
- package/src/lib/components/sprite.js +98 -0
- package/src/lib/components/widget.js +122 -0
- package/src/lib/fire-utils.js +58 -392
- package/src/lib/node-utils.js +359 -0
- package/src/lib/templates.js +212 -0
- package/src/lib/utils.js +139 -0
- package/src/commands/delete.js +0 -74
- package/src/commands/remove-component.js +0 -63
- package/src/lib/components.js +0 -404
|
@@ -0,0 +1,359 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 节点工具模块
|
|
3
|
+
* 提供节点创建、属性设置、删除等功能
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { generateId, generateUUID, parseColorToCcColor, colorToHex } = require('./utils');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 创建节点数据
|
|
10
|
+
* @param {string} name - 节点名称
|
|
11
|
+
* @param {number} parentId - 父节点索引
|
|
12
|
+
* @param {object} options - 可选参数
|
|
13
|
+
* @returns {object} 节点数据
|
|
14
|
+
*/
|
|
15
|
+
function createNodeData(name, parentId, options = {}) {
|
|
16
|
+
return {
|
|
17
|
+
"__type__": "cc.Node",
|
|
18
|
+
"_name": name,
|
|
19
|
+
"_objFlags": 0,
|
|
20
|
+
"_parent": { "__id__": parentId },
|
|
21
|
+
"_children": [],
|
|
22
|
+
"_active": options.active !== false,
|
|
23
|
+
"_components": [],
|
|
24
|
+
"_prefab": options._prefab || null,
|
|
25
|
+
"_opacity": options.opacity !== undefined ? options.opacity : 255,
|
|
26
|
+
"_color": parseColorToCcColor(options.color) || {
|
|
27
|
+
"__type__": "cc.Color",
|
|
28
|
+
"r": 255, "g": 255, "b": 255, "a": 255
|
|
29
|
+
},
|
|
30
|
+
"_contentSize": {
|
|
31
|
+
"__type__": "cc.Size",
|
|
32
|
+
"width": options.width || 0,
|
|
33
|
+
"height": options.height || 0
|
|
34
|
+
},
|
|
35
|
+
"_anchorPoint": {
|
|
36
|
+
"__type__": "cc.Vec2",
|
|
37
|
+
"x": options.anchorX !== undefined ? options.anchorX : 0.5,
|
|
38
|
+
"y": options.anchorY !== undefined ? options.anchorY : 0.5
|
|
39
|
+
},
|
|
40
|
+
"_trs": {
|
|
41
|
+
"__type__": "TypedArray",
|
|
42
|
+
"ctor": "Float64Array",
|
|
43
|
+
"array": [
|
|
44
|
+
options.x || 0,
|
|
45
|
+
options.y || 0,
|
|
46
|
+
0, 0, 0,
|
|
47
|
+
(options.rotation || 0) * Math.PI / 180,
|
|
48
|
+
1,
|
|
49
|
+
options.scaleX !== undefined ? options.scaleX : 1,
|
|
50
|
+
options.scaleY !== undefined ? options.scaleY : 1,
|
|
51
|
+
1
|
|
52
|
+
]
|
|
53
|
+
},
|
|
54
|
+
"_eulerAngles": {
|
|
55
|
+
"__type__": "cc.Vec3",
|
|
56
|
+
"x": 0, "y": 0,
|
|
57
|
+
"z": options.rotation || 0
|
|
58
|
+
},
|
|
59
|
+
"_skewX": 0,
|
|
60
|
+
"_skewY": 0,
|
|
61
|
+
"_is3DNode": false,
|
|
62
|
+
"_groupIndex": options.group || 0,
|
|
63
|
+
"groupIndex": options.group || 0,
|
|
64
|
+
"_id": generateUUID()
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 设置节点属性
|
|
70
|
+
* @param {object} node - 节点对象
|
|
71
|
+
* @param {string} key - 属性名
|
|
72
|
+
* @param {*} value - 属性值
|
|
73
|
+
*/
|
|
74
|
+
function setNodeProperty(node, key, value) {
|
|
75
|
+
switch (key) {
|
|
76
|
+
case 'name':
|
|
77
|
+
node._name = value;
|
|
78
|
+
break;
|
|
79
|
+
case 'active':
|
|
80
|
+
node._active = value !== 'false' && value !== false;
|
|
81
|
+
break;
|
|
82
|
+
case 'x':
|
|
83
|
+
case 'y':
|
|
84
|
+
if (!node._trs) {
|
|
85
|
+
node._trs = { "__type__": "TypedArray", "ctor": "Float64Array", "array": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] };
|
|
86
|
+
}
|
|
87
|
+
node._trs.array[key === 'x' ? 0 : 1] = parseFloat(value);
|
|
88
|
+
break;
|
|
89
|
+
case 'width':
|
|
90
|
+
case 'height':
|
|
91
|
+
if (!node._contentSize) {
|
|
92
|
+
node._contentSize = { "__type__": "cc.Size", "width": 0, "height": 0 };
|
|
93
|
+
}
|
|
94
|
+
node._contentSize[key] = parseFloat(value);
|
|
95
|
+
break;
|
|
96
|
+
case 'anchorX':
|
|
97
|
+
case 'anchorY':
|
|
98
|
+
if (!node._anchorPoint) {
|
|
99
|
+
node._anchorPoint = { "__type__": "cc.Vec2", "x": 0.5, "y": 0.5 };
|
|
100
|
+
}
|
|
101
|
+
node._anchorPoint[key === 'anchorX' ? 'x' : 'y'] = parseFloat(value);
|
|
102
|
+
break;
|
|
103
|
+
case 'opacity':
|
|
104
|
+
node._opacity = Math.max(0, Math.min(255, parseInt(value)));
|
|
105
|
+
break;
|
|
106
|
+
case 'color':
|
|
107
|
+
const color = parseColorToCcColor(value);
|
|
108
|
+
if (color) node._color = color;
|
|
109
|
+
break;
|
|
110
|
+
case 'rotation':
|
|
111
|
+
if (!node._eulerAngles) {
|
|
112
|
+
node._eulerAngles = { "__type__": "cc.Vec3", "x": 0, "y": 0, "z": 0 };
|
|
113
|
+
}
|
|
114
|
+
node._eulerAngles.z = parseFloat(value);
|
|
115
|
+
break;
|
|
116
|
+
case 'scaleX':
|
|
117
|
+
case 'scaleY':
|
|
118
|
+
if (!node._trs) {
|
|
119
|
+
node._trs = { "__type__": "TypedArray", "ctor": "Float64Array", "array": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] };
|
|
120
|
+
}
|
|
121
|
+
node._trs.array[key === 'scaleX' ? 7 : 8] = parseFloat(value);
|
|
122
|
+
break;
|
|
123
|
+
case 'group':
|
|
124
|
+
node._groupIndex = parseInt(value);
|
|
125
|
+
node.groupIndex = node._groupIndex;
|
|
126
|
+
break;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* 批量设置节点属性
|
|
132
|
+
* @param {object} node - 节点对象
|
|
133
|
+
* @param {object} options - 属性对象
|
|
134
|
+
*/
|
|
135
|
+
function setNodeProperties(node, options) {
|
|
136
|
+
if (!options) return;
|
|
137
|
+
for (const [key, value] of Object.entries(options)) {
|
|
138
|
+
setNodeProperty(node, key, value);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 获取节点状态
|
|
144
|
+
* @param {Array} data - 场景/预制体数据数组
|
|
145
|
+
* @param {object} node - 节点对象
|
|
146
|
+
* @param {number} nodeIndex - 节点索引
|
|
147
|
+
* @returns {object} 节点状态
|
|
148
|
+
*/
|
|
149
|
+
function getNodeState(data, node, nodeIndex) {
|
|
150
|
+
const { extractComponentProps } = require('./components');
|
|
151
|
+
const trs = node._trs?.array || [0, 0, 0, 0, 0, 0, 1, 1, 1, 1];
|
|
152
|
+
const components = (node._components || []).map(ref => extractComponentProps(data[ref.__id__]));
|
|
153
|
+
const children = (node._children || []).map(ref => data[ref.__id__]?._name || '(unknown)');
|
|
154
|
+
|
|
155
|
+
const result = {
|
|
156
|
+
name: node._name,
|
|
157
|
+
active: node._active,
|
|
158
|
+
position: { x: trs[0], y: trs[1] },
|
|
159
|
+
rotation: node._eulerAngles?.z ?? 0,
|
|
160
|
+
scale: { x: trs[7], y: trs[8] },
|
|
161
|
+
anchor: { x: node._anchorPoint?.x ?? 0.5, y: node._anchorPoint?.y ?? 0.5 },
|
|
162
|
+
size: { w: node._contentSize?.width ?? 0, h: node._contentSize?.height ?? 0 },
|
|
163
|
+
color: colorToHex(node._color),
|
|
164
|
+
opacity: node._opacity ?? 255,
|
|
165
|
+
group: node._groupIndex ?? 0
|
|
166
|
+
};
|
|
167
|
+
|
|
168
|
+
if (children.length > 0) result.children = children;
|
|
169
|
+
if (components.length > 0) result.components = components;
|
|
170
|
+
|
|
171
|
+
return result;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* 收集节点及其所有子节点和组件的索引
|
|
176
|
+
* @param {Array} data - 场景数据
|
|
177
|
+
* @param {number} nodeIndex - 节点索引
|
|
178
|
+
* @param {Set} collected - 已收集的索引集合
|
|
179
|
+
* @returns {Set} 收集的索引集合
|
|
180
|
+
*/
|
|
181
|
+
function collectNodeAndChildren(data, nodeIndex, collected = new Set()) {
|
|
182
|
+
if (collected.has(nodeIndex)) return collected;
|
|
183
|
+
|
|
184
|
+
const node = data[nodeIndex];
|
|
185
|
+
if (!node) return collected;
|
|
186
|
+
|
|
187
|
+
collected.add(nodeIndex);
|
|
188
|
+
|
|
189
|
+
// 收集所有组件
|
|
190
|
+
if (node._components) {
|
|
191
|
+
for (const compRef of node._components) {
|
|
192
|
+
collected.add(compRef.__id__);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
// 递归收集子节点
|
|
197
|
+
if (node._children) {
|
|
198
|
+
for (const childRef of node._children) {
|
|
199
|
+
collectNodeAndChildren(data, childRef.__id__, collected);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return collected;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/**
|
|
207
|
+
* 从父节点的 _children 中移除节点引用
|
|
208
|
+
* @param {Array} data - 场景数据
|
|
209
|
+
* @param {object} node - 要删除的节点
|
|
210
|
+
* @param {number} nodeIndex - 节点索引
|
|
211
|
+
*/
|
|
212
|
+
function removeFromParent(data, node, nodeIndex) {
|
|
213
|
+
if (node._parent) {
|
|
214
|
+
const parentIndex = node._parent.__id__;
|
|
215
|
+
const parent = data[parentIndex];
|
|
216
|
+
if (parent && parent._children) {
|
|
217
|
+
parent._children = parent._children.filter(c => c.__id__ !== nodeIndex);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* 删除节点
|
|
224
|
+
* @param {Array} data - 场景数据
|
|
225
|
+
* @param {number} nodeIndex - 节点索引
|
|
226
|
+
* @param {Function} rebuildReferences - 重建引用函数
|
|
227
|
+
* @returns {object} 删除结果
|
|
228
|
+
*/
|
|
229
|
+
function deleteNode(data, nodeIndex, rebuildReferences) {
|
|
230
|
+
if (nodeIndex <= 1) {
|
|
231
|
+
return { error: '不能删除根节点' };
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
const node = data[nodeIndex];
|
|
235
|
+
if (!node) {
|
|
236
|
+
return { error: `节点索引 ${nodeIndex} 不存在` };
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const nodeName = node._name || '(unnamed)';
|
|
240
|
+
|
|
241
|
+
// 收集所有需要删除的索引
|
|
242
|
+
const indicesToDelete = collectNodeAndChildren(data, nodeIndex);
|
|
243
|
+
|
|
244
|
+
// 从父节点移除引用
|
|
245
|
+
removeFromParent(data, node, nodeIndex);
|
|
246
|
+
|
|
247
|
+
// 重建引用
|
|
248
|
+
rebuildReferences(data, indicesToDelete);
|
|
249
|
+
|
|
250
|
+
// 删除元素(从大到小排序)
|
|
251
|
+
const sortedIndices = Array.from(indicesToDelete).sort((a, b) => b - a);
|
|
252
|
+
for (const idx of sortedIndices) {
|
|
253
|
+
data.splice(idx, 1);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
return {
|
|
257
|
+
success: true,
|
|
258
|
+
nodeName,
|
|
259
|
+
nodeIndex,
|
|
260
|
+
deletedCount: sortedIndices.length
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
/**
|
|
265
|
+
* 构建节点树输出
|
|
266
|
+
* @param {Array} data - 场景数据
|
|
267
|
+
* @param {object} scriptMap - 脚本映射
|
|
268
|
+
* @param {number} nodeIndex - 节点索引
|
|
269
|
+
* @param {string} prefix - 前缀
|
|
270
|
+
* @param {boolean} isLast - 是否是最后一个子节点
|
|
271
|
+
* @param {boolean} isRoot - 是否是根节点
|
|
272
|
+
* @returns {string} 树形字符串
|
|
273
|
+
*/
|
|
274
|
+
function buildTree(data, scriptMap, nodeIndex, prefix = '', isLast = true, isRoot = true) {
|
|
275
|
+
const node = data[nodeIndex];
|
|
276
|
+
if (!node) return '';
|
|
277
|
+
|
|
278
|
+
const isSceneRoot = node.__type__ === 'cc.Scene';
|
|
279
|
+
const nodeName = isRoot ? 'Root' : (node._name || '(unnamed)');
|
|
280
|
+
const active = node._active !== false ? '●' : '○';
|
|
281
|
+
const uuidRegex = /^[a-f0-9]{8}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{4}-[a-f0-9]{12}$/i;
|
|
282
|
+
|
|
283
|
+
let result = '';
|
|
284
|
+
|
|
285
|
+
if (isSceneRoot) {
|
|
286
|
+
result = prefix + '[Scene]\n';
|
|
287
|
+
} else {
|
|
288
|
+
result = prefix + (isRoot ? '' : active + ' ') + nodeName + ' #' + nodeIndex;
|
|
289
|
+
|
|
290
|
+
// 添加组件信息
|
|
291
|
+
if (node._components && node._components.length > 0) {
|
|
292
|
+
const comps = node._components.map(c => {
|
|
293
|
+
const comp = data[c.__id__];
|
|
294
|
+
if (!comp) return `? #${c.__id__}`;
|
|
295
|
+
const typeName = comp.__type__;
|
|
296
|
+
let displayName;
|
|
297
|
+
if (uuidRegex.test(typeName)) {
|
|
298
|
+
const scriptInfo = scriptMap[typeName];
|
|
299
|
+
displayName = (scriptInfo && scriptInfo.name) ? scriptInfo.name : '[MissingScript]';
|
|
300
|
+
} else if (typeName === 'MissingScript') {
|
|
301
|
+
displayName = '[MissingScript]';
|
|
302
|
+
} else {
|
|
303
|
+
displayName = typeName.replace('cc.', '');
|
|
304
|
+
}
|
|
305
|
+
return `${displayName} #${c.__id__}`;
|
|
306
|
+
}).join(', ');
|
|
307
|
+
result += ` (${comps})`;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
result += '\n';
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// 处理子节点
|
|
314
|
+
if (node._children && node._children.length > 0) {
|
|
315
|
+
node._children.forEach((childRef, idx) => {
|
|
316
|
+
const childIsLast = idx === node._children.length - 1;
|
|
317
|
+
const childPrefix = prefix + (isSceneRoot ? '' : (isRoot ? '' : (isLast ? ' ' : '│ ')));
|
|
318
|
+
result += buildTree(data, scriptMap, childRef.__id__, childPrefix, childIsLast, isSceneRoot);
|
|
319
|
+
});
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return result;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
/**
|
|
326
|
+
* 判断索引指向的是节点还是组件
|
|
327
|
+
* @param {Array} data - 场景数据
|
|
328
|
+
* @param {number} index - 索引
|
|
329
|
+
* @returns {string|null} 'node' 或 'component' 或 null
|
|
330
|
+
*/
|
|
331
|
+
function detectItemType(data, index) {
|
|
332
|
+
const item = data[index];
|
|
333
|
+
if (!item) return null;
|
|
334
|
+
|
|
335
|
+
// 组件有 node 属性指向所属节点
|
|
336
|
+
if (item.node !== undefined) {
|
|
337
|
+
return 'component';
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
// 节点有 _name 或类型为 cc.Node/cc.Scene
|
|
341
|
+
const itemType = item.__type__;
|
|
342
|
+
if (itemType === 'cc.Node' || itemType === 'cc.Scene' || item._name !== undefined) {
|
|
343
|
+
return 'node';
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return 'component';
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
module.exports = {
|
|
350
|
+
createNodeData,
|
|
351
|
+
setNodeProperty,
|
|
352
|
+
setNodeProperties,
|
|
353
|
+
getNodeState,
|
|
354
|
+
collectNodeAndChildren,
|
|
355
|
+
removeFromParent,
|
|
356
|
+
deleteNode,
|
|
357
|
+
buildTree,
|
|
358
|
+
detectItemType
|
|
359
|
+
};
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模板模块
|
|
3
|
+
* 提供预制体和场景的基础模板
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const { generateUUID } = require('./utils');
|
|
7
|
+
const { generateFileId } = require('./fire-utils');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* 创建预制体基础结构
|
|
11
|
+
* @param {string} name - 预制体名称
|
|
12
|
+
* @returns {Array} 预制体数据数组
|
|
13
|
+
*/
|
|
14
|
+
function createPrefab(name) {
|
|
15
|
+
const fileId = generateFileId();
|
|
16
|
+
return [
|
|
17
|
+
{
|
|
18
|
+
"__type__": "cc.Prefab",
|
|
19
|
+
"_name": "",
|
|
20
|
+
"_objFlags": 0,
|
|
21
|
+
"_native": "",
|
|
22
|
+
"data": { "__id__": 1 },
|
|
23
|
+
"optimizationPolicy": 0,
|
|
24
|
+
"asyncLoadAssets": false,
|
|
25
|
+
"readonly": false
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"__type__": "cc.Node",
|
|
29
|
+
"_name": name,
|
|
30
|
+
"_objFlags": 0,
|
|
31
|
+
"_parent": null,
|
|
32
|
+
"_children": [],
|
|
33
|
+
"_active": true,
|
|
34
|
+
"_components": [],
|
|
35
|
+
"_prefab": { "__id__": 2 },
|
|
36
|
+
"_opacity": 255,
|
|
37
|
+
"_color": { "__type__": "cc.Color", "r": 255, "g": 255, "b": 255, "a": 255 },
|
|
38
|
+
"_contentSize": { "__type__": "cc.Size", "width": 0, "height": 0 },
|
|
39
|
+
"_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, "y": 0.5 },
|
|
40
|
+
"_trs": { "__type__": "TypedArray", "ctor": "Float64Array", "array": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] },
|
|
41
|
+
"_eulerAngles": { "__type__": "cc.Vec3", "x": 0, "y": 0, "z": 0 },
|
|
42
|
+
"_skewX": 0,
|
|
43
|
+
"_skewY": 0,
|
|
44
|
+
"_is3DNode": false,
|
|
45
|
+
"_groupIndex": 0,
|
|
46
|
+
"groupIndex": 0,
|
|
47
|
+
"_id": ""
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"__type__": "cc.PrefabInfo",
|
|
51
|
+
"root": { "__id__": 1 },
|
|
52
|
+
"asset": { "__id__": 0 },
|
|
53
|
+
"fileId": fileId,
|
|
54
|
+
"sync": false
|
|
55
|
+
}
|
|
56
|
+
];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 创建场景基础结构
|
|
61
|
+
* @param {string} sceneName - 场景名称
|
|
62
|
+
* @returns {Array} 场景数据数组
|
|
63
|
+
*/
|
|
64
|
+
function createScene(sceneName) {
|
|
65
|
+
const sceneUUID = generateUUID();
|
|
66
|
+
const canvasUUID = generateUUID();
|
|
67
|
+
const cameraUUID = generateUUID();
|
|
68
|
+
|
|
69
|
+
return [
|
|
70
|
+
// 索引 0: cc.SceneAsset
|
|
71
|
+
{
|
|
72
|
+
"__type__": "cc.SceneAsset",
|
|
73
|
+
"_name": sceneName || "NewScene",
|
|
74
|
+
"_objFlags": 0,
|
|
75
|
+
"_native": "",
|
|
76
|
+
"scene": { "__id__": 1 }
|
|
77
|
+
},
|
|
78
|
+
// 索引 1: cc.Scene
|
|
79
|
+
{
|
|
80
|
+
"__type__": "cc.Scene",
|
|
81
|
+
"_name": sceneName || "NewScene",
|
|
82
|
+
"_objFlags": 0,
|
|
83
|
+
"_parent": null,
|
|
84
|
+
"_children": [{ "__id__": 2 }],
|
|
85
|
+
"_active": true,
|
|
86
|
+
"_components": [],
|
|
87
|
+
"_prefab": null,
|
|
88
|
+
"_opacity": 255,
|
|
89
|
+
"_color": { "__type__": "cc.Color", "r": 255, "g": 255, "b": 255, "a": 255 },
|
|
90
|
+
"_contentSize": { "__type__": "cc.Size", "width": 0, "height": 0 },
|
|
91
|
+
"_anchorPoint": { "__type__": "cc.Vec2", "x": 0, "y": 0 },
|
|
92
|
+
"_trs": { "__type__": "TypedArray", "ctor": "Float64Array", "array": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] },
|
|
93
|
+
"_is3DNode": true,
|
|
94
|
+
"_groupIndex": 0,
|
|
95
|
+
"groupIndex": 0,
|
|
96
|
+
"autoReleaseAssets": false,
|
|
97
|
+
"_id": sceneUUID
|
|
98
|
+
},
|
|
99
|
+
// 索引 2: Canvas 节点
|
|
100
|
+
{
|
|
101
|
+
"__type__": "cc.Node",
|
|
102
|
+
"_name": "Canvas",
|
|
103
|
+
"_objFlags": 0,
|
|
104
|
+
"_parent": { "__id__": 1 },
|
|
105
|
+
"_children": [{ "__id__": 3 }],
|
|
106
|
+
"_active": true,
|
|
107
|
+
"_components": [{ "__id__": 5 }, { "__id__": 6 }],
|
|
108
|
+
"_prefab": null,
|
|
109
|
+
"_opacity": 255,
|
|
110
|
+
"_color": { "__type__": "cc.Color", "r": 255, "g": 255, "b": 255, "a": 255 },
|
|
111
|
+
"_contentSize": { "__type__": "cc.Size", "width": 960, "height": 640 },
|
|
112
|
+
"_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, "y": 0.5 },
|
|
113
|
+
"_trs": { "__type__": "TypedArray", "ctor": "Float64Array", "array": [480, 320, 0, 0, 0, 0, 1, 1, 1, 1] },
|
|
114
|
+
"_eulerAngles": { "__type__": "cc.Vec3", "x": 0, "y": 0, "z": 0 },
|
|
115
|
+
"_skewX": 0,
|
|
116
|
+
"_skewY": 0,
|
|
117
|
+
"_is3DNode": false,
|
|
118
|
+
"_groupIndex": 0,
|
|
119
|
+
"groupIndex": 0,
|
|
120
|
+
"_id": canvasUUID
|
|
121
|
+
},
|
|
122
|
+
// 索引 3: Main Camera 节点
|
|
123
|
+
{
|
|
124
|
+
"__type__": "cc.Node",
|
|
125
|
+
"_name": "Main Camera",
|
|
126
|
+
"_objFlags": 0,
|
|
127
|
+
"_parent": { "__id__": 2 },
|
|
128
|
+
"_children": [],
|
|
129
|
+
"_active": true,
|
|
130
|
+
"_components": [{ "__id__": 4 }],
|
|
131
|
+
"_prefab": null,
|
|
132
|
+
"_opacity": 255,
|
|
133
|
+
"_color": { "__type__": "cc.Color", "r": 255, "g": 255, "b": 255, "a": 255 },
|
|
134
|
+
"_contentSize": { "__type__": "cc.Size", "width": 0, "height": 0 },
|
|
135
|
+
"_anchorPoint": { "__type__": "cc.Vec2", "x": 0.5, "y": 0.5 },
|
|
136
|
+
"_trs": { "__type__": "TypedArray", "ctor": "Float64Array", "array": [0, 0, 0, 0, 0, 0, 1, 1, 1, 1] },
|
|
137
|
+
"_eulerAngles": { "__type__": "cc.Vec3", "x": 0, "y": 0, "z": 0 },
|
|
138
|
+
"_skewX": 0,
|
|
139
|
+
"_skewY": 0,
|
|
140
|
+
"_is3DNode": false,
|
|
141
|
+
"_groupIndex": 0,
|
|
142
|
+
"groupIndex": 0,
|
|
143
|
+
"_id": cameraUUID
|
|
144
|
+
},
|
|
145
|
+
// 索引 4: Camera 组件
|
|
146
|
+
{
|
|
147
|
+
"__type__": "cc.Camera",
|
|
148
|
+
"_name": "",
|
|
149
|
+
"_objFlags": 0,
|
|
150
|
+
"node": { "__id__": 3 },
|
|
151
|
+
"_enabled": true,
|
|
152
|
+
"_cullingMask": 4294967295,
|
|
153
|
+
"_clearFlags": 7,
|
|
154
|
+
"_backgroundColor": { "__type__": "cc.Color", "r": 0, "g": 0, "b": 0, "a": 255 },
|
|
155
|
+
"_depth": -1,
|
|
156
|
+
"_zoomRatio": 1,
|
|
157
|
+
"_targetTexture": null,
|
|
158
|
+
"_fov": 60,
|
|
159
|
+
"_orthoSize": 10,
|
|
160
|
+
"_nearClip": 1,
|
|
161
|
+
"_farClip": 4096,
|
|
162
|
+
"_ortho": true,
|
|
163
|
+
"_rect": { "__type__": "cc.Rect", "x": 0, "y": 0, "width": 1, "height": 1 },
|
|
164
|
+
"_renderStages": 1,
|
|
165
|
+
"_alignWithScreen": true,
|
|
166
|
+
"_id": ""
|
|
167
|
+
},
|
|
168
|
+
// 索引 5: Canvas 组件
|
|
169
|
+
{
|
|
170
|
+
"__type__": "cc.Canvas",
|
|
171
|
+
"_name": "",
|
|
172
|
+
"_objFlags": 0,
|
|
173
|
+
"node": { "__id__": 2 },
|
|
174
|
+
"_enabled": true,
|
|
175
|
+
"_designResolution": { "__type__": "cc.Size", "width": 960, "height": 640 },
|
|
176
|
+
"_fitWidth": false,
|
|
177
|
+
"_fitHeight": true,
|
|
178
|
+
"_id": ""
|
|
179
|
+
},
|
|
180
|
+
// 索引 6: Widget 组件 (Canvas)
|
|
181
|
+
{
|
|
182
|
+
"__type__": "cc.Widget",
|
|
183
|
+
"_name": "",
|
|
184
|
+
"_objFlags": 0,
|
|
185
|
+
"node": { "__id__": 2 },
|
|
186
|
+
"_enabled": true,
|
|
187
|
+
"alignMode": 1,
|
|
188
|
+
"_target": null,
|
|
189
|
+
"_alignFlags": 45,
|
|
190
|
+
"_left": 0,
|
|
191
|
+
"_right": 0,
|
|
192
|
+
"_top": 0,
|
|
193
|
+
"_bottom": 0,
|
|
194
|
+
"_verticalCenter": 0,
|
|
195
|
+
"_horizontalCenter": 0,
|
|
196
|
+
"_isAbsLeft": true,
|
|
197
|
+
"_isAbsRight": true,
|
|
198
|
+
"_isAbsTop": true,
|
|
199
|
+
"_isAbsBottom": true,
|
|
200
|
+
"_isAbsHorizontalCenter": true,
|
|
201
|
+
"_isAbsVerticalCenter": true,
|
|
202
|
+
"_originalWidth": 0,
|
|
203
|
+
"_originalHeight": 0,
|
|
204
|
+
"_id": ""
|
|
205
|
+
}
|
|
206
|
+
];
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
module.exports = {
|
|
210
|
+
createPrefab,
|
|
211
|
+
createScene
|
|
212
|
+
};
|