sunrize 1.7.29 → 1.7.31
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/package.json +6 -45
- package/src/Application/Document.js +12 -0
- package/src/Editors/Library.js +5 -3
- package/src/Editors/NodeList.js +2 -6
- package/src/Editors/OutlineView.js +93 -53
- package/src/Tools/Core/X3DNodeTool.js +5 -2
- package/src/Undo/Editor.js +166 -88
- package/src/assets/Entitlements.plist +24 -0
- package/src/assets/Info.plist +8 -8
- package/src/assets/themes/default-template.css +5 -3
- package/src/assets/themes/default.css +5 -3
- package/src/Application/Traverse.js +0 -368
|
@@ -1,368 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
const X3D = require ("../X3D");
|
|
4
|
-
|
|
5
|
-
let flags = 1;
|
|
6
|
-
|
|
7
|
-
module .exports = class Traverse
|
|
8
|
-
{
|
|
9
|
-
static NONE = 0;
|
|
10
|
-
static EXTERNPROTO_DECLARATIONS = flags;
|
|
11
|
-
static PROTO_DECLARATIONS = flags <<= 1;
|
|
12
|
-
static ROOT_NODES = flags <<= 1;
|
|
13
|
-
static IMPORTED_NODES = flags <<= 1;
|
|
14
|
-
static EXTERNPROTO_DECLARATION_SCENE = flags <<= 1;
|
|
15
|
-
static PROTO_DECLARATION_BODY = flags <<= 1;
|
|
16
|
-
static PROTOTYPE_INSTANCES = flags <<= 1;
|
|
17
|
-
static INLINE_SCENE = flags <<= 1;
|
|
18
|
-
static ALL = (flags << 1) - 1;
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
*
|
|
22
|
-
* @param {X3DScene|X3DExecutionContext|MFNode|Array<SFNode>|SFNode} object
|
|
23
|
-
* @param {number} flags
|
|
24
|
-
* @param {Function} callback
|
|
25
|
-
* @returns boolean
|
|
26
|
-
*/
|
|
27
|
-
static traverse (object, flags, callback)
|
|
28
|
-
{
|
|
29
|
-
const seen = new Set ()
|
|
30
|
-
|
|
31
|
-
if (object instanceof X3D .X3DExecutionContext)
|
|
32
|
-
return this .traverseScene (object, flags, callback, seen);
|
|
33
|
-
|
|
34
|
-
if (object instanceof X3D .MFNode || Array .isArray (object))
|
|
35
|
-
return this .traverseNodes (object, flags, callback, seen);
|
|
36
|
-
|
|
37
|
-
if (object instanceof X3D .SFNode)
|
|
38
|
-
return this .traverseNode (object .getValue (), flags, callback, seen);
|
|
39
|
-
|
|
40
|
-
if (object instanceof X3D .X3DBaseNode)
|
|
41
|
-
return this .traverseNode (object, flags, callback, seen);
|
|
42
|
-
|
|
43
|
-
return false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
static traverseScene (executionContext, flags, callback, seen)
|
|
47
|
-
{
|
|
48
|
-
if (!executionContext)
|
|
49
|
-
return true;
|
|
50
|
-
|
|
51
|
-
if (flags & Traverse .PROTO_DECLARATIONS)
|
|
52
|
-
{
|
|
53
|
-
for (const proto of executionContext .protos)
|
|
54
|
-
{
|
|
55
|
-
if (this .traverseNode (proto, flags, callback, seen) === false)
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
if (flags & Traverse .ROOT_NODES)
|
|
61
|
-
{
|
|
62
|
-
if (this .traverseNodes (executionContext .rootNodes, flags, callback, seen) === false)
|
|
63
|
-
return false;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return callback (executionContext) !== false;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
static traverseNodes (nodes, flags, callback, seen)
|
|
70
|
-
{
|
|
71
|
-
for (const node of nodes)
|
|
72
|
-
{
|
|
73
|
-
if (this .traverseNode (node instanceof X3D .SFNode ? node .getValue () : node, flags, callback, seen) === false)
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
return true;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
static traverseNode (node, flags, callback, seen)
|
|
81
|
-
{
|
|
82
|
-
if (!node)
|
|
83
|
-
return true;
|
|
84
|
-
|
|
85
|
-
if (seen .has (node))
|
|
86
|
-
return true;
|
|
87
|
-
|
|
88
|
-
seen .add (node);
|
|
89
|
-
|
|
90
|
-
if (this .traverseFields (node .getUserDefinedFields (), flags, callback, seen) === false)
|
|
91
|
-
return false;
|
|
92
|
-
|
|
93
|
-
if (this .traverseFields (node .getPredefinedFields (), flags, callback, seen) === false)
|
|
94
|
-
return false;
|
|
95
|
-
|
|
96
|
-
const type = node .getType ();
|
|
97
|
-
|
|
98
|
-
for (let t = type .length - 1; t >= 0; -- t)
|
|
99
|
-
{
|
|
100
|
-
switch (type [t])
|
|
101
|
-
{
|
|
102
|
-
case X3D .X3DConstants .X3DExternProtoDeclaration:
|
|
103
|
-
{
|
|
104
|
-
if (flags & this .EXTERNPROTO_DECLARATION_SCENE)
|
|
105
|
-
{
|
|
106
|
-
if (this .traverseScene (node .getInternalScene (), flags, callback, seen) === false)
|
|
107
|
-
return false;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case X3D .X3DConstants .X3DProtoDeclaration:
|
|
113
|
-
{
|
|
114
|
-
if (flags & Traverse .PROTO_DECLARATION_BODY)
|
|
115
|
-
{
|
|
116
|
-
if (this .traverseScene (node .getBody (), flags, callback, seen) === false)
|
|
117
|
-
return false;
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
break;
|
|
121
|
-
}
|
|
122
|
-
case X3D .X3DConstants .X3DPrototypeInstance:
|
|
123
|
-
{
|
|
124
|
-
if (flags & Traverse .PROTOTYPE_INSTANCES)
|
|
125
|
-
{
|
|
126
|
-
if (this .traverseScene (node .getBody (), flags, callback, seen) === false)
|
|
127
|
-
return false;
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
break;
|
|
131
|
-
}
|
|
132
|
-
case X3D .X3DConstants .Inline:
|
|
133
|
-
{
|
|
134
|
-
if (flags & this .INLINE_SCENE)
|
|
135
|
-
{
|
|
136
|
-
if (this .traverseScene (node .getInternalScene (), flags, callback, seen) === false)
|
|
137
|
-
return false;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
break;
|
|
141
|
-
}
|
|
142
|
-
default:
|
|
143
|
-
{
|
|
144
|
-
continue;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
break;
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return callback (node) !== false;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
static traverseFields (fields, flags, callback, seen)
|
|
155
|
-
{
|
|
156
|
-
for (const field of fields)
|
|
157
|
-
{
|
|
158
|
-
switch (field .getType ())
|
|
159
|
-
{
|
|
160
|
-
case X3D .X3DConstants .SFNode:
|
|
161
|
-
{
|
|
162
|
-
if (this .traverseNode (field .getValue (), flags, callback, seen) === false)
|
|
163
|
-
return false;
|
|
164
|
-
|
|
165
|
-
break;
|
|
166
|
-
}
|
|
167
|
-
case X3D .X3DConstants .MFNode:
|
|
168
|
-
{
|
|
169
|
-
if (this .traverseNodes (field, flags, callback, seen) === false)
|
|
170
|
-
return false;
|
|
171
|
-
|
|
172
|
-
break;
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return true;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
static find (scene, object, flags)
|
|
181
|
-
{
|
|
182
|
-
const
|
|
183
|
-
hierarchies = [ ],
|
|
184
|
-
hierarchy = [ ],
|
|
185
|
-
seen = new Set ();
|
|
186
|
-
|
|
187
|
-
this .findInScene (scene, object, flags, hierarchies, hierarchy, seen);
|
|
188
|
-
|
|
189
|
-
return hierarchies;
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
static findInScene (executionContext, object, flags, hierarchies, hierarchy, seen)
|
|
193
|
-
{
|
|
194
|
-
if (!executionContext)
|
|
195
|
-
return;
|
|
196
|
-
|
|
197
|
-
hierarchy .push (executionContext);
|
|
198
|
-
|
|
199
|
-
if (executionContext === object)
|
|
200
|
-
{
|
|
201
|
-
hierarchies .push (hierarchy .slice ());
|
|
202
|
-
}
|
|
203
|
-
else
|
|
204
|
-
{
|
|
205
|
-
if (flags & this .EXTERNPROTO_DECLARATIONS)
|
|
206
|
-
{
|
|
207
|
-
const externprotos = executionContext .getExternProtoDeclarations ();
|
|
208
|
-
|
|
209
|
-
for (const externproto of externprotos)
|
|
210
|
-
{
|
|
211
|
-
this .findInNode (externproto, object, flags, hierarchies, hierarchy, seen);
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
if (flags & this .PROTO_DECLARATIONS)
|
|
216
|
-
{
|
|
217
|
-
const prototypes = executionContext .getProtoDeclarations ();
|
|
218
|
-
|
|
219
|
-
for (const prototype of prototypes)
|
|
220
|
-
{
|
|
221
|
-
this .findInNode (prototype, object, flags, hierarchies, hierarchy, seen);
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
if (flags & this .ROOT_NODES)
|
|
226
|
-
{
|
|
227
|
-
const rootNodes = executionContext .getRootNodes ();
|
|
228
|
-
|
|
229
|
-
for (const rootNode of rootNodes)
|
|
230
|
-
{
|
|
231
|
-
this .findInNode (rootNode .getValue (), object, flags, hierarchies, hierarchy, seen);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
if (flags & this .IMPORTED_NODES)
|
|
236
|
-
{
|
|
237
|
-
for (const importedNode of executionContext .getImportedNodes ())
|
|
238
|
-
{
|
|
239
|
-
hierarchy .push (importedNode);
|
|
240
|
-
|
|
241
|
-
if (importedNode === object)
|
|
242
|
-
{
|
|
243
|
-
hierarchies .push (hierarchy .slice ());
|
|
244
|
-
}
|
|
245
|
-
else
|
|
246
|
-
{
|
|
247
|
-
try
|
|
248
|
-
{
|
|
249
|
-
const exportedNode = importedNode .getExportedNode ();
|
|
250
|
-
|
|
251
|
-
this .findInNode (exportedNode, object, flags, hierarchies, hierarchy, seen);
|
|
252
|
-
}
|
|
253
|
-
catch (error)
|
|
254
|
-
{
|
|
255
|
-
//console .log (error .message)
|
|
256
|
-
}
|
|
257
|
-
}
|
|
258
|
-
|
|
259
|
-
hierarchy .pop ();
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
hierarchy .pop ();
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
static findInNode (node, object, flags, hierarchies, hierarchy, seen)
|
|
268
|
-
{
|
|
269
|
-
if (!node)
|
|
270
|
-
return;
|
|
271
|
-
|
|
272
|
-
if (seen .has (node))
|
|
273
|
-
return;
|
|
274
|
-
|
|
275
|
-
seen .add (node);
|
|
276
|
-
hierarchy .push (node);
|
|
277
|
-
|
|
278
|
-
if (node .valueOf () === object .valueOf ())
|
|
279
|
-
{
|
|
280
|
-
hierarchies .push (hierarchy .slice ());
|
|
281
|
-
}
|
|
282
|
-
else
|
|
283
|
-
{
|
|
284
|
-
if (!node .getType () .includes (X3D .X3DConstants .X3DExternProtoDeclaration))
|
|
285
|
-
{
|
|
286
|
-
this .findInFields (node .getUserDefinedFields (), object, flags, hierarchies, hierarchy, seen);
|
|
287
|
-
this .findInFields (node .getPredefinedFields (), object, flags, hierarchies, hierarchy, seen);
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const type = node .getType ();
|
|
291
|
-
|
|
292
|
-
for (let t = type .length - 1; t >= 0; -- t)
|
|
293
|
-
{
|
|
294
|
-
switch (type [t])
|
|
295
|
-
{
|
|
296
|
-
case X3D .X3DConstants .X3DExternProtoDeclaration:
|
|
297
|
-
{
|
|
298
|
-
if (flags & this .EXTERNPROTO_DECLARATION_SCENE)
|
|
299
|
-
this .findInScene (node .getInternalScene (), object, flags, hierarchies, hierarchy, seen);
|
|
300
|
-
|
|
301
|
-
break;
|
|
302
|
-
}
|
|
303
|
-
case X3D .X3DConstants .X3DProtoDeclaration:
|
|
304
|
-
{
|
|
305
|
-
if (flags & this .PROTO_DECLARATION_BODY)
|
|
306
|
-
this .findInScene (node .getBody (), object, flags, hierarchies, hierarchy, seen);
|
|
307
|
-
|
|
308
|
-
break;
|
|
309
|
-
}
|
|
310
|
-
case X3D .X3DConstants .X3DPrototypeInstance:
|
|
311
|
-
{
|
|
312
|
-
if (flags & this .PROTOTYPE_INSTANCES)
|
|
313
|
-
this .findInScene (node .getBody (), object, flags, hierarchies, hierarchy, seen);
|
|
314
|
-
|
|
315
|
-
break;
|
|
316
|
-
}
|
|
317
|
-
case X3D .X3DConstants .Inline:
|
|
318
|
-
{
|
|
319
|
-
if (flags & this .INLINE_SCENE)
|
|
320
|
-
this .findInScene (node .getInternalScene (), object, flags, hierarchies, hierarchy, seen);
|
|
321
|
-
|
|
322
|
-
break
|
|
323
|
-
}
|
|
324
|
-
default:
|
|
325
|
-
break;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
|
|
330
|
-
hierarchy .pop ();
|
|
331
|
-
seen .delete (node);
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
static findInFields (fields, object, flags, hierarchies, hierarchy, seen)
|
|
335
|
-
{
|
|
336
|
-
for (const field of fields)
|
|
337
|
-
{
|
|
338
|
-
hierarchy .push (field);
|
|
339
|
-
|
|
340
|
-
if (field === object)
|
|
341
|
-
{
|
|
342
|
-
hierarchies .push (hierarchy .slice ());
|
|
343
|
-
}
|
|
344
|
-
else
|
|
345
|
-
{
|
|
346
|
-
switch (field .getType ())
|
|
347
|
-
{
|
|
348
|
-
case X3D .X3DConstants .SFNode:
|
|
349
|
-
{
|
|
350
|
-
this .findInNode (field .getValue (), object, flags, hierarchies, hierarchy, seen);
|
|
351
|
-
break;
|
|
352
|
-
}
|
|
353
|
-
case X3D .X3DConstants .MFNode:
|
|
354
|
-
{
|
|
355
|
-
for (const node of field)
|
|
356
|
-
this .findInNode (node ?.getValue (), object, flags, hierarchies, hierarchy, seen);
|
|
357
|
-
|
|
358
|
-
break;
|
|
359
|
-
}
|
|
360
|
-
default:
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
hierarchy .pop ();
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
};
|