@margoengine/loaders 0.0.0-stage → 0.1.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/LICENSE +201 -0
- package/NOTICE +4 -0
- package/README.md +1198 -3
- package/dist/3dm.d.ts +161 -0
- package/dist/3dm.js +289 -0
- package/dist/3ds.d.ts +124 -0
- package/dist/3ds.js +392 -0
- package/dist/acclaim.d.ts +90 -0
- package/dist/acclaim.js +312 -0
- package/dist/amf.d.ts +45 -0
- package/dist/amf.js +256 -0
- package/dist/babylon.d.ts +197 -0
- package/dist/babylon.js +701 -0
- package/dist/common.d.ts +7 -0
- package/dist/common.js +6 -0
- package/dist/dae-animation.d.ts +66 -0
- package/dist/dae-animation.js +266 -0
- package/dist/dae-common.d.ts +95 -0
- package/dist/dae-common.js +226 -0
- package/dist/dae-controllers.d.ts +57 -0
- package/dist/dae-controllers.js +164 -0
- package/dist/dae-pose.d.ts +131 -0
- package/dist/dae-pose.js +381 -0
- package/dist/dae-scene.d.ts +203 -0
- package/dist/dae-scene.js +279 -0
- package/dist/dae.d.ts +161 -0
- package/dist/dae.js +633 -0
- package/dist/detect.d.ts +20 -0
- package/dist/detect.js +72 -0
- package/dist/dxf.d.ts +81 -0
- package/dist/dxf.js +774 -0
- package/dist/engine.d.ts +36 -0
- package/dist/engine.js +117 -0
- package/dist/font-opentype.d.ts +14 -0
- package/dist/font-opentype.js +33 -0
- package/dist/font-woff.d.ts +23 -0
- package/dist/font-woff.js +293 -0
- package/dist/font.d.ts +41 -0
- package/dist/font.js +26 -0
- package/dist/gcode.d.ts +55 -0
- package/dist/gcode.js +278 -0
- package/dist/geo-model.d.ts +84 -0
- package/dist/geo-model.js +220 -0
- package/dist/geo-mvt.d.ts +15 -0
- package/dist/geo-mvt.js +302 -0
- package/dist/geo-shp.d.ts +15 -0
- package/dist/geo-shp.js +234 -0
- package/dist/geo-xml.d.ts +6 -0
- package/dist/geo-xml.js +165 -0
- package/dist/geo.d.ts +8 -0
- package/dist/geo.js +59 -0
- package/dist/geometry.d.ts +60 -0
- package/dist/geometry.js +273 -0
- package/dist/index.d.ts +54 -0
- package/dist/index.js +28 -0
- package/dist/kmz.d.ts +78 -0
- package/dist/kmz.js +173 -0
- package/dist/las.d.ts +92 -0
- package/dist/las.js +110 -0
- package/dist/ldraw.d.ts +118 -0
- package/dist/ldraw.js +474 -0
- package/dist/load.d.ts +72 -0
- package/dist/load.js +205 -0
- package/dist/lottie.d.ts +154 -0
- package/dist/lottie.js +893 -0
- package/dist/lwo.d.ts +81 -0
- package/dist/lwo.js +454 -0
- package/dist/lzf.d.ts +13 -0
- package/dist/lzf.js +56 -0
- package/dist/materialx.d.ts +120 -0
- package/dist/materialx.js +563 -0
- package/dist/md2.d.ts +52 -0
- package/dist/md2.js +112 -0
- package/dist/mmcif.d.ts +14 -0
- package/dist/mmcif.js +246 -0
- package/dist/mmd.d.ts +244 -0
- package/dist/mmd.js +958 -0
- package/dist/mocap.d.ts +71 -0
- package/dist/mocap.js +178 -0
- package/dist/molecule-common.d.ts +4 -0
- package/dist/molecule-common.js +54 -0
- package/dist/mtl.d.ts +120 -0
- package/dist/mtl.js +469 -0
- package/dist/normals.d.ts +7 -0
- package/dist/normals.js +31 -0
- package/dist/nrrd.d.ts +63 -0
- package/dist/nrrd.js +743 -0
- package/dist/nurbs.d.ts +118 -0
- package/dist/nurbs.js +265 -0
- package/dist/obj.d.ts +143 -0
- package/dist/obj.js +456 -0
- package/dist/off.d.ts +10 -0
- package/dist/off.js +155 -0
- package/dist/outline-font.d.ts +87 -0
- package/dist/outline-font.js +110 -0
- package/dist/outline.d.ts +20 -0
- package/dist/outline.js +215 -0
- package/dist/pcd.d.ts +34 -0
- package/dist/pcd.js +258 -0
- package/dist/pdb.d.ts +67 -0
- package/dist/pdb.js +126 -0
- package/dist/ply.d.ts +35 -0
- package/dist/ply.js +392 -0
- package/dist/polygon.d.ts +9 -0
- package/dist/polygon.js +49 -0
- package/dist/prwm.d.ts +24 -0
- package/dist/prwm.js +114 -0
- package/dist/render.d.ts +27 -0
- package/dist/render.js +153 -0
- package/dist/sfnt-cff.d.ts +37 -0
- package/dist/sfnt-cff.js +749 -0
- package/dist/sfnt-layout.d.ts +24 -0
- package/dist/sfnt-layout.js +266 -0
- package/dist/sfnt-reader.d.ts +28 -0
- package/dist/sfnt-reader.js +87 -0
- package/dist/sfnt-variation.d.ts +40 -0
- package/dist/sfnt-variation.js +318 -0
- package/dist/shared/asset-url.js +82 -0
- package/dist/shared/crc32.d.ts +2 -0
- package/dist/shared/crc32.js +47 -0
- package/dist/shared/errors.js +36 -0
- package/dist/shared/inflate.js +284 -0
- package/dist/shared/normals.js +26 -0
- package/dist/shared/scene-scope.js +56 -0
- package/dist/shared/trailing-data.js +42 -0
- package/dist/stl.d.ts +64 -0
- package/dist/stl.js +309 -0
- package/dist/svg.d.ts +90 -0
- package/dist/svg.js +1007 -0
- package/dist/tds.d.ts +2 -0
- package/dist/tds.js +2 -0
- package/dist/textures.d.ts +42 -0
- package/dist/textures.js +53 -0
- package/dist/threemf-lattice.d.ts +139 -0
- package/dist/threemf-lattice.js +514 -0
- package/dist/threemf-materials.d.ts +75 -0
- package/dist/threemf-materials.js +314 -0
- package/dist/threemf-mesh.d.ts +60 -0
- package/dist/threemf-mesh.js +201 -0
- package/dist/threemf.d.ts +101 -0
- package/dist/threemf.js +415 -0
- package/dist/tilt.d.ts +62 -0
- package/dist/tilt.js +186 -0
- package/dist/tmx.d.ts +151 -0
- package/dist/tmx.js +394 -0
- package/dist/ttf.d.ts +78 -0
- package/dist/ttf.js +568 -0
- package/dist/types.d.ts +90 -0
- package/dist/types.js +35 -0
- package/dist/usd.d.ts +2 -0
- package/dist/usd.js +2 -0
- package/dist/usd.worker.d.ts +1 -0
- package/dist/usdz.d.ts +50 -0
- package/dist/usdz.js +646 -0
- package/dist/util.d.ts +75 -0
- package/dist/util.js +241 -0
- package/dist/vdb.d.ts +111 -0
- package/dist/vdb.js +663 -0
- package/dist/vrml.d.ts +53 -0
- package/dist/vrml.js +532 -0
- package/dist/vtk-cells.d.ts +29 -0
- package/dist/vtk-cells.js +211 -0
- package/dist/vtk-legacy.d.ts +57 -0
- package/dist/vtk-legacy.js +439 -0
- package/dist/vtk-reader.d.ts +19 -0
- package/dist/vtk-reader.js +134 -0
- package/dist/vtk-xml.d.ts +96 -0
- package/dist/vtk-xml.js +578 -0
- package/dist/vtk.d.ts +13 -0
- package/dist/vtk.js +234 -0
- package/dist/woff-glyf.d.ts +17 -0
- package/dist/woff-glyf.js +215 -0
- package/dist/worker.d.ts +10 -0
- package/dist/worker.js +93 -0
- package/dist/workers/usd.js +3 -0
- package/dist/xfile.d.ts +99 -0
- package/dist/xfile.js +706 -0
- package/dist/xml.d.ts +107 -0
- package/dist/xml.js +843 -0
- package/dist/xyz.d.ts +16 -0
- package/dist/xyz.js +110 -0
- package/dist/zip.d.ts +38 -0
- package/dist/zip.js +150 -0
- package/package.json +246 -6
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
// @ts-ignore optional peer: its types apply when it is installed
|
|
2
|
+
import type { MaterialGraph } from '@margoengine/materials';
|
|
3
|
+
import { type BinaryInput } from './util.js';
|
|
4
|
+
import { type XMLExternalOptions } from './xml.js';
|
|
5
|
+
/** One input of a node: a value, or a connection to a node, a node graph output or a graph interface input. */
|
|
6
|
+
export interface MaterialXInput {
|
|
7
|
+
name: string;
|
|
8
|
+
type: string;
|
|
9
|
+
/** The `value` attribute parsed by `type`: a number, boolean, string or array of numbers. */
|
|
10
|
+
value?: number | boolean | string | number[];
|
|
11
|
+
nodename?: string;
|
|
12
|
+
nodegraph?: string;
|
|
13
|
+
output?: string;
|
|
14
|
+
interfacename?: string;
|
|
15
|
+
/** This input's `colorspace`, else the nearest one above it in the document. */
|
|
16
|
+
colorspace?: string;
|
|
17
|
+
/** The `fileprefix` in force here, already joined to a `filename` value. */
|
|
18
|
+
fileprefix?: string;
|
|
19
|
+
}
|
|
20
|
+
/** One node: a surface shader, an image, a maths operation. */
|
|
21
|
+
export interface MaterialXNode {
|
|
22
|
+
/** The element name, such as `standard_surface`. */
|
|
23
|
+
category: string;
|
|
24
|
+
name: string;
|
|
25
|
+
type: string;
|
|
26
|
+
/** Inputs by name. Null prototype. */
|
|
27
|
+
inputs: Record<string, MaterialXInput>;
|
|
28
|
+
/** The `version` attribute, such as `1.0.0`: which published definition of the node it means. */
|
|
29
|
+
version?: string;
|
|
30
|
+
/** The `nodedef` attribute: the definition it names outright. */
|
|
31
|
+
nodedef?: string;
|
|
32
|
+
}
|
|
33
|
+
/** A `nodegraph`: nodes, its named outputs and the inputs it takes from outside. */
|
|
34
|
+
export interface MaterialXNodeGraph {
|
|
35
|
+
name: string;
|
|
36
|
+
/** Nodes by name. Null prototype. */
|
|
37
|
+
nodes: Record<string, MaterialXNode>;
|
|
38
|
+
/** Outputs by name. Null prototype. */
|
|
39
|
+
outputs: Record<string, MaterialXInput>;
|
|
40
|
+
/** Interface inputs by name. Null prototype. */
|
|
41
|
+
inputs: Record<string, MaterialXInput>;
|
|
42
|
+
}
|
|
43
|
+
/** A `surfacematerial` node with its surface shader found. */
|
|
44
|
+
export interface MaterialXMaterial {
|
|
45
|
+
name: string;
|
|
46
|
+
/** The connected surface shader, or null when it is missing or inside a graph this reader cannot follow. */
|
|
47
|
+
shader: MaterialXNode | null;
|
|
48
|
+
}
|
|
49
|
+
/** A `materialassign` of a `look`. */
|
|
50
|
+
export interface MaterialXAssignment {
|
|
51
|
+
look: string;
|
|
52
|
+
material: string;
|
|
53
|
+
geom?: string;
|
|
54
|
+
collection?: string;
|
|
55
|
+
}
|
|
56
|
+
/** A request for one image of {@link MaterialXConvertOptions.texture}. */
|
|
57
|
+
export interface MaterialXTextureRequest {
|
|
58
|
+
/** The path as written, with its `fileprefix`. */
|
|
59
|
+
file: string;
|
|
60
|
+
/** The node's output type: `float`, `color3`, `vector3` and so on. */
|
|
61
|
+
type: string;
|
|
62
|
+
/** `srgb_texture` or `srgb_rec709_scene` means upload as sRGB. Absent means linear data. */
|
|
63
|
+
colorspace?: string;
|
|
64
|
+
/** The node's `uaddressmode`, `vaddressmode` and `filtertype` values, when set. */
|
|
65
|
+
addressU?: string;
|
|
66
|
+
addressV?: string;
|
|
67
|
+
filter?: string;
|
|
68
|
+
}
|
|
69
|
+
/** A texture of a node material: caller-owned, as `@margoengine/materials` takes it. */
|
|
70
|
+
export interface MaterialXTexture {
|
|
71
|
+
view: GPUTextureView;
|
|
72
|
+
sampler?: GPUSampler;
|
|
73
|
+
}
|
|
74
|
+
/** Options of {@link MaterialXDocument.toGraph}. */
|
|
75
|
+
export interface MaterialXConvertOptions {
|
|
76
|
+
/** Loads one image. Each file, colour space and type is asked for once. Without this hook, image inputs are skipped. */
|
|
77
|
+
texture?: (request: MaterialXTextureRequest) => MaterialXTexture | Promise<MaterialXTexture>;
|
|
78
|
+
signal?: AbortSignal;
|
|
79
|
+
}
|
|
80
|
+
/** Something of the document that the node material could not hold. */
|
|
81
|
+
export interface MaterialXSkip {
|
|
82
|
+
/** The shader input, such as `emission`. */
|
|
83
|
+
input: string;
|
|
84
|
+
/** Why, in words. */
|
|
85
|
+
reason: string;
|
|
86
|
+
}
|
|
87
|
+
/** What {@link MaterialXDocument.toGraph} returns. Pass `graph` to `nodeMaterial()` or `installNodeMaterial()`. */
|
|
88
|
+
export interface MaterialXConversion {
|
|
89
|
+
graph: MaterialGraph;
|
|
90
|
+
/** What did not convert. The input keeps its value, or the shader's default. Empty when all of it converted. */
|
|
91
|
+
skipped: MaterialXSkip[];
|
|
92
|
+
}
|
|
93
|
+
/** What {@link parseMaterialX} returns. */
|
|
94
|
+
export interface MaterialXDocument {
|
|
95
|
+
/** The `version` attribute, such as `1.39`. */
|
|
96
|
+
version: string;
|
|
97
|
+
/** The document's `colorspace`, when set. */
|
|
98
|
+
colorspace?: string;
|
|
99
|
+
/** Top-level nodes by name. Null prototype. */
|
|
100
|
+
nodes: Record<string, MaterialXNode>;
|
|
101
|
+
/** Node graphs by name. Null prototype. */
|
|
102
|
+
graphs: Record<string, MaterialXNodeGraph>;
|
|
103
|
+
materials: MaterialXMaterial[];
|
|
104
|
+
assignments: MaterialXAssignment[];
|
|
105
|
+
/** `xi:include` targets, which this reader does not follow. */
|
|
106
|
+
includes: string[];
|
|
107
|
+
/** Converts one material, by name or the first by default, to a node material graph. */
|
|
108
|
+
toGraph(material?: string, options?: MaterialXConvertOptions): Promise<MaterialXConversion>;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Reads a MaterialX document (1.38 and later): its nodes, node graphs, surface materials and looks. `toGraph` turns a
|
|
112
|
+
* `standard_surface`, `open_pbr_surface`, `gltf_pbr` or `UsdPreviewSurface` material into the object graph that
|
|
113
|
+
* `nodeMaterial()` of `@margoengine/materials` takes.
|
|
114
|
+
*
|
|
115
|
+
* @throws LoaderError code `header` when the root is not `<materialx>`, `syntax` for a bad value or a missing name,
|
|
116
|
+
* `unsupported` for a document of 1.37 or before.
|
|
117
|
+
*/
|
|
118
|
+
export declare function parseMaterialX(input: BinaryInput | string, options?: XMLExternalOptions): MaterialXDocument;
|
|
119
|
+
/** A document from parts, for a network that came from elsewhere, such as a USD stage. `nodes` have a null prototype. */
|
|
120
|
+
export declare function materialXDocument(parts: Partial<Omit<MaterialXDocument, 'toGraph'>> & Pick<MaterialXDocument, 'nodes' | 'materials'>): MaterialXDocument;
|
|
@@ -0,0 +1,563 @@
|
|
|
1
|
+
import { SRGBToLinear } from '@margoengine/math/color';
|
|
2
|
+
import { LoaderError } from './types.js';
|
|
3
|
+
import { throwIfAborted, toText } from './util.js';
|
|
4
|
+
import { readXMLTree } from './xml.js';
|
|
5
|
+
const F = 'MaterialX';
|
|
6
|
+
const MAX_DEPTH = 256;
|
|
7
|
+
const COUNTS = {
|
|
8
|
+
color3: 3,
|
|
9
|
+
color4: 4,
|
|
10
|
+
vector2: 2,
|
|
11
|
+
vector3: 3,
|
|
12
|
+
vector4: 4,
|
|
13
|
+
matrix33: 9,
|
|
14
|
+
matrix44: 16,
|
|
15
|
+
};
|
|
16
|
+
function parseValue(text, type) {
|
|
17
|
+
if (type === 'float' || type === 'integer') {
|
|
18
|
+
const value = Number(text);
|
|
19
|
+
if (text.trim() === '' || !Number.isFinite(value))
|
|
20
|
+
throw new LoaderError(F, 'syntax', `bad ${type} "${text}"`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
if (type === 'boolean') {
|
|
24
|
+
if (text !== 'true' && text !== 'false')
|
|
25
|
+
throw new LoaderError(F, 'syntax', `bad boolean "${text}"`);
|
|
26
|
+
return text === 'true';
|
|
27
|
+
}
|
|
28
|
+
if (!Object.hasOwn(COUNTS, type))
|
|
29
|
+
return text;
|
|
30
|
+
const count = COUNTS[type];
|
|
31
|
+
// The specification separates with commas, and real files also write `0.5 0.5`, which OpenUSD reads.
|
|
32
|
+
const values = text
|
|
33
|
+
.trim()
|
|
34
|
+
.split(/\s*,\s*|\s+/)
|
|
35
|
+
.map((part) => Number(part));
|
|
36
|
+
if (values.length !== count || values.some((value) => !Number.isFinite(value)))
|
|
37
|
+
throw new LoaderError(F, 'syntax', `bad ${type} "${text}"`);
|
|
38
|
+
return values;
|
|
39
|
+
}
|
|
40
|
+
function scoped(element, scope) {
|
|
41
|
+
const { colorspace, fileprefix } = element.attributes;
|
|
42
|
+
return {
|
|
43
|
+
colorspace: colorspace ?? scope.colorspace,
|
|
44
|
+
// An inner fileprefix replaces the enclosing one (MaterialX Specification, File Prefixes).
|
|
45
|
+
fileprefix: fileprefix ?? scope.fileprefix,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function readInput(element, scope) {
|
|
49
|
+
const { name, type, value, nodename, nodegraph, output, interfacename } = element.attributes, here = scoped(element, scope);
|
|
50
|
+
if (!name)
|
|
51
|
+
throw new LoaderError(F, 'syntax', `<${element.name}> has no name`);
|
|
52
|
+
const input = { name, type: type ?? '' };
|
|
53
|
+
if (value !== undefined) {
|
|
54
|
+
input.value = parseValue(value, input.type);
|
|
55
|
+
if (input.type === 'filename' && here.fileprefix)
|
|
56
|
+
input.value = here.fileprefix + value;
|
|
57
|
+
}
|
|
58
|
+
if (nodename !== undefined)
|
|
59
|
+
input.nodename = nodename;
|
|
60
|
+
if (nodegraph !== undefined)
|
|
61
|
+
input.nodegraph = nodegraph;
|
|
62
|
+
if (output !== undefined)
|
|
63
|
+
input.output = output;
|
|
64
|
+
if (interfacename !== undefined)
|
|
65
|
+
input.interfacename = interfacename;
|
|
66
|
+
if (here.colorspace !== undefined)
|
|
67
|
+
input.colorspace = here.colorspace;
|
|
68
|
+
if (here.fileprefix !== undefined)
|
|
69
|
+
input.fileprefix = here.fileprefix;
|
|
70
|
+
return input;
|
|
71
|
+
}
|
|
72
|
+
const table = () => Object.create(null);
|
|
73
|
+
function readNode(element, scope) {
|
|
74
|
+
const { name, type, version, nodedef } = element.attributes, here = scoped(element, scope);
|
|
75
|
+
if (!name)
|
|
76
|
+
throw new LoaderError(F, 'syntax', `<${element.name}> has no name`);
|
|
77
|
+
const inputs = table();
|
|
78
|
+
for (const child of element.children)
|
|
79
|
+
if (child.name === 'input' || child.name === 'token') {
|
|
80
|
+
const input = readInput(child, here);
|
|
81
|
+
inputs[input.name] = input;
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
category: element.name,
|
|
85
|
+
name,
|
|
86
|
+
type: type ?? '',
|
|
87
|
+
inputs,
|
|
88
|
+
...(version ? { version } : {}),
|
|
89
|
+
...(nodedef ? { nodedef } : {}),
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
/** Elements of a document that are not nodes. */
|
|
93
|
+
const NOT_NODES = new Set([
|
|
94
|
+
'nodedef',
|
|
95
|
+
'implementation',
|
|
96
|
+
'typedef',
|
|
97
|
+
'unit',
|
|
98
|
+
'unitdef',
|
|
99
|
+
'unittypedef',
|
|
100
|
+
'geominfo',
|
|
101
|
+
'geompropdef',
|
|
102
|
+
'collection',
|
|
103
|
+
'variantset',
|
|
104
|
+
'propertyset',
|
|
105
|
+
'propertysetassign',
|
|
106
|
+
'attributedef',
|
|
107
|
+
'targetdef',
|
|
108
|
+
'token',
|
|
109
|
+
'input',
|
|
110
|
+
'output',
|
|
111
|
+
'look',
|
|
112
|
+
'lookgroup',
|
|
113
|
+
'backdrop',
|
|
114
|
+
'nodegraph',
|
|
115
|
+
'include',
|
|
116
|
+
'material',
|
|
117
|
+
]);
|
|
118
|
+
function readGraph(element, scope) {
|
|
119
|
+
const { name } = element.attributes, here = scoped(element, scope);
|
|
120
|
+
if (!name)
|
|
121
|
+
throw new LoaderError(F, 'syntax', '<nodegraph> has no name');
|
|
122
|
+
const graph = {
|
|
123
|
+
name,
|
|
124
|
+
nodes: table(),
|
|
125
|
+
outputs: table(),
|
|
126
|
+
inputs: table(),
|
|
127
|
+
};
|
|
128
|
+
for (const child of element.children) {
|
|
129
|
+
if (child.name === 'output') {
|
|
130
|
+
const output = readInput(child, here);
|
|
131
|
+
graph.outputs[output.name] = output;
|
|
132
|
+
}
|
|
133
|
+
else if (child.name === 'input') {
|
|
134
|
+
const input = readInput(child, here);
|
|
135
|
+
graph.inputs[input.name] = input;
|
|
136
|
+
}
|
|
137
|
+
else if (!NOT_NODES.has(child.name)) {
|
|
138
|
+
const node = readNode(child, here);
|
|
139
|
+
graph.nodes[node.name] = node;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return graph;
|
|
143
|
+
}
|
|
144
|
+
// Defaults from each shader's published definition.
|
|
145
|
+
const SURFACES = {
|
|
146
|
+
standard_surface: {
|
|
147
|
+
color: ['base_color', [0.8, 0.8, 0.8]],
|
|
148
|
+
weight: ['base', 1],
|
|
149
|
+
metal: ['metalness', 0],
|
|
150
|
+
roughness: ['specular_roughness', 0.2],
|
|
151
|
+
normal: 'normal',
|
|
152
|
+
coat: ['coat', 0],
|
|
153
|
+
coatRoughness: ['coat_roughness', 0.1],
|
|
154
|
+
transmission: ['transmission', 0],
|
|
155
|
+
ior: ['specular_IOR', 1.5],
|
|
156
|
+
},
|
|
157
|
+
open_pbr_surface: {
|
|
158
|
+
color: ['base_color', [0.8, 0.8, 0.8]],
|
|
159
|
+
weight: ['base_weight', 1],
|
|
160
|
+
metal: ['base_metalness', 0],
|
|
161
|
+
roughness: ['specular_roughness', 0.3],
|
|
162
|
+
normal: 'geometry_normal',
|
|
163
|
+
coat: ['coat_weight', 0],
|
|
164
|
+
coatRoughness: ['coat_roughness', 0],
|
|
165
|
+
transmission: ['transmission_weight', 0],
|
|
166
|
+
ior: ['specular_ior', 1.5],
|
|
167
|
+
},
|
|
168
|
+
gltf_pbr: {
|
|
169
|
+
color: ['base_color', [1, 1, 1]],
|
|
170
|
+
metal: ['metallic', 1],
|
|
171
|
+
roughness: ['roughness', 1],
|
|
172
|
+
normal: 'normal',
|
|
173
|
+
coat: ['clearcoat', 0],
|
|
174
|
+
coatRoughness: ['clearcoat_roughness', 0],
|
|
175
|
+
transmission: ['transmission', 0],
|
|
176
|
+
ior: ['ior', 1.5],
|
|
177
|
+
},
|
|
178
|
+
realitykit_pbr_surfaceshader: {
|
|
179
|
+
color: ['baseColor', [0.18, 0.18, 0.18]],
|
|
180
|
+
metal: ['metallic', 0],
|
|
181
|
+
roughness: ['roughness', 0.5],
|
|
182
|
+
normal: 'normal',
|
|
183
|
+
coat: ['clearcoat', 0],
|
|
184
|
+
coatRoughness: ['clearcoatRoughness', 0.01],
|
|
185
|
+
transmission: ['transmission', 0],
|
|
186
|
+
ior: ['ior', 1.5],
|
|
187
|
+
},
|
|
188
|
+
UsdPreviewSurface: {
|
|
189
|
+
color: ['diffuseColor', [0.18, 0.18, 0.18]],
|
|
190
|
+
metal: ['metallic', 0],
|
|
191
|
+
roughness: ['roughness', 0.5],
|
|
192
|
+
normal: 'normal',
|
|
193
|
+
coat: ['clearcoat', 0],
|
|
194
|
+
coatRoughness: ['clearcoatRoughness', 0.01],
|
|
195
|
+
transmission: ['transmission', 0],
|
|
196
|
+
ior: ['ior', 1.5],
|
|
197
|
+
},
|
|
198
|
+
};
|
|
199
|
+
/** Inputs that change nothing here: they carry no look, or the graph already behaves that way. */
|
|
200
|
+
const IGNORED = new Set([
|
|
201
|
+
'tangent',
|
|
202
|
+
'geometry_tangent',
|
|
203
|
+
'geometry_coat_tangent',
|
|
204
|
+
'coat_normal',
|
|
205
|
+
'geometry_coat_normal',
|
|
206
|
+
]);
|
|
207
|
+
/** The node material colour space of a constant: `linear`, `srgb`, or null for one that cannot be converted here. */
|
|
208
|
+
function constantSpace(colorspace) {
|
|
209
|
+
if (colorspace === undefined || colorspace === '' || /^(?:lin_rec709(?:_scene)?|none|data)$/.test(colorspace))
|
|
210
|
+
return 'linear';
|
|
211
|
+
return colorspace === 'srgb_texture' || colorspace === 'srgb_rec709_scene' ? 'srgb' : null;
|
|
212
|
+
}
|
|
213
|
+
/** The older definition of `standard_surface`, which a node asks for by name: same look, split the other way. */
|
|
214
|
+
const STANDARD_SURFACE_100 = {
|
|
215
|
+
...SURFACES.standard_surface,
|
|
216
|
+
color: ['base_color', [1, 1, 1]],
|
|
217
|
+
weight: ['base', 0.8],
|
|
218
|
+
};
|
|
219
|
+
const surfaceOf = (shader) => {
|
|
220
|
+
if (shader.category === 'standard_surface' &&
|
|
221
|
+
(shader.version === '1.0.0' || shader.nodedef === 'ND_standard_surface_surfaceshader_100'))
|
|
222
|
+
return STANDARD_SURFACE_100;
|
|
223
|
+
return Object.hasOwn(SURFACES, shader.category) ? SURFACES[shader.category] : undefined;
|
|
224
|
+
};
|
|
225
|
+
/** One conversion of one material: follows connections, shares nodes, and notes what it drops. */
|
|
226
|
+
class Converter {
|
|
227
|
+
constructor(doc, options) {
|
|
228
|
+
this.doc = doc;
|
|
229
|
+
this.options = options;
|
|
230
|
+
this.skipped = [];
|
|
231
|
+
this.done = new Map();
|
|
232
|
+
this.images = new Map();
|
|
233
|
+
this.path = new Set();
|
|
234
|
+
}
|
|
235
|
+
skip(input, reason) {
|
|
236
|
+
if (!this.skipped.some((item) => item.input === input && item.reason === reason))
|
|
237
|
+
this.skipped.push({ input, reason });
|
|
238
|
+
}
|
|
239
|
+
/** What an input is connected to: the node, and the graph it lives in. Null for a plain value. */
|
|
240
|
+
follow(input, graph, depth = 0) {
|
|
241
|
+
if (depth > MAX_DEPTH)
|
|
242
|
+
throw new LoaderError(F, 'range', `input ${input.name} is connected in a loop`);
|
|
243
|
+
if (input.interfacename !== undefined) {
|
|
244
|
+
const outer = graph?.inputs[input.interfacename];
|
|
245
|
+
if (!outer)
|
|
246
|
+
throw new LoaderError(F, 'syntax', `no interface input ${input.interfacename}`);
|
|
247
|
+
return this.follow(outer, null, depth + 1);
|
|
248
|
+
}
|
|
249
|
+
if (input.nodegraph !== undefined) {
|
|
250
|
+
const target = this.doc.graphs[input.nodegraph];
|
|
251
|
+
if (!target)
|
|
252
|
+
throw new LoaderError(F, 'syntax', `no node graph ${input.nodegraph}`);
|
|
253
|
+
const outputs = Object.values(target.outputs), output = input.output === undefined ? outputs[0] : target.outputs[input.output];
|
|
254
|
+
if (!output)
|
|
255
|
+
throw new LoaderError(F, 'syntax', `no output ${input.output} in ${input.nodegraph}`);
|
|
256
|
+
return this.follow(output, target, depth + 1);
|
|
257
|
+
}
|
|
258
|
+
if (input.nodename !== undefined) {
|
|
259
|
+
const node = graph?.nodes[input.nodename] ?? this.doc.nodes[input.nodename];
|
|
260
|
+
if (!node)
|
|
261
|
+
throw new LoaderError(F, 'syntax', `no node ${input.nodename}`);
|
|
262
|
+
return { node, graph: graph?.nodes[input.nodename] ? graph : null };
|
|
263
|
+
}
|
|
264
|
+
return { node: null, graph, value: input };
|
|
265
|
+
}
|
|
266
|
+
/** A constant input as a node: numbers to `scalar`, colours and vectors to `color`. */
|
|
267
|
+
constant(input, slot) {
|
|
268
|
+
const { value } = input;
|
|
269
|
+
if (typeof value === 'number')
|
|
270
|
+
return { type: 'scalar', value };
|
|
271
|
+
if (!Array.isArray(value))
|
|
272
|
+
return null;
|
|
273
|
+
let [r = 0, g = 0, b = 0, a = 1] = value;
|
|
274
|
+
if (input.type === 'color3' || input.type === 'color4') {
|
|
275
|
+
const space = constantSpace(input.colorspace);
|
|
276
|
+
if (!space)
|
|
277
|
+
this.skip(slot, `colour space ${input.colorspace} is not converted; the value is read as linear`);
|
|
278
|
+
if (space === 'srgb')
|
|
279
|
+
[r, g, b] = [SRGBToLinear(r), SRGBToLinear(g), SRGBToLinear(b)];
|
|
280
|
+
}
|
|
281
|
+
else if (value.length < 4)
|
|
282
|
+
a = 1;
|
|
283
|
+
return { type: 'color', value: [r, g, b, a] };
|
|
284
|
+
}
|
|
285
|
+
/** An input of a node inside the conversion; a missing one takes `fallback`. */
|
|
286
|
+
async operand(node, name, graph, slot, fallback) {
|
|
287
|
+
const input = node.inputs[name];
|
|
288
|
+
return input ? this.value(input, graph, slot) : { type: 'scalar', value: fallback };
|
|
289
|
+
}
|
|
290
|
+
async image(node, slot) {
|
|
291
|
+
const file = node.inputs.file, hook = this.options.texture;
|
|
292
|
+
if (typeof file?.value !== 'string' || file.value === '') {
|
|
293
|
+
this.skip(slot, `image ${node.name} names no file`);
|
|
294
|
+
return null;
|
|
295
|
+
}
|
|
296
|
+
if (!hook) {
|
|
297
|
+
this.skip(slot, `image ${file.value} needs options.texture`);
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
300
|
+
const scale = node.inputs.uvtiling?.value, offset = node.inputs.uvoffset?.value;
|
|
301
|
+
if (Array.isArray(scale) && scale.some((v) => v !== 1))
|
|
302
|
+
this.skip(slot, `uvtiling of ${node.name} is not applied`);
|
|
303
|
+
if (Array.isArray(offset) && offset.some((v) => v !== 0))
|
|
304
|
+
this.skip(slot, `uvoffset of ${node.name} is not applied`);
|
|
305
|
+
const text = (name) => {
|
|
306
|
+
const { value } = node.inputs[name] ?? {};
|
|
307
|
+
return typeof value === 'string' ? value : undefined;
|
|
308
|
+
}, colorspace = file.colorspace, request = { file: file.value, type: node.type };
|
|
309
|
+
if (colorspace)
|
|
310
|
+
request.colorspace = colorspace;
|
|
311
|
+
const addressU = text('uaddressmode'), addressV = text('vaddressmode'), filter = text('filtertype');
|
|
312
|
+
if (addressU)
|
|
313
|
+
request.addressU = addressU;
|
|
314
|
+
if (addressV)
|
|
315
|
+
request.addressV = addressV;
|
|
316
|
+
if (filter)
|
|
317
|
+
request.filter = filter;
|
|
318
|
+
const id = `${node.type}\n${colorspace ?? ''}\n${file.value}`;
|
|
319
|
+
let texture = this.images.get(id);
|
|
320
|
+
if (!texture) {
|
|
321
|
+
texture = Promise.resolve(hook(request));
|
|
322
|
+
this.images.set(id, texture);
|
|
323
|
+
}
|
|
324
|
+
// A float image reads the file's first channel, as MaterialX does, so it mixes and weighs as a scalar.
|
|
325
|
+
return node.type === 'float'
|
|
326
|
+
? { type: 'texture', texture: await texture, channel: 0 }
|
|
327
|
+
: { type: 'texture', texture: await texture };
|
|
328
|
+
}
|
|
329
|
+
async build(node, graph, slot) {
|
|
330
|
+
const both = async (first, second, fallback) => {
|
|
331
|
+
const a = await this.operand(node, first, graph, slot, fallback), b = await this.operand(node, second, graph, slot, fallback);
|
|
332
|
+
return a && b ? [a, b] : null;
|
|
333
|
+
};
|
|
334
|
+
switch (node.category) {
|
|
335
|
+
case 'image':
|
|
336
|
+
case 'tiledimage':
|
|
337
|
+
case 'gltf_image':
|
|
338
|
+
return this.image(node, slot);
|
|
339
|
+
case 'constant':
|
|
340
|
+
case 'dot':
|
|
341
|
+
case 'convert': {
|
|
342
|
+
const name = node.category === 'constant' ? 'value' : 'in', input = node.inputs[name];
|
|
343
|
+
return input ? this.value(input, graph, slot) : null;
|
|
344
|
+
}
|
|
345
|
+
case 'add': {
|
|
346
|
+
const pair = await both('in1', 'in2', 0);
|
|
347
|
+
return pair && { type: 'add', a: pair[0], b: pair[1] };
|
|
348
|
+
}
|
|
349
|
+
case 'multiply': {
|
|
350
|
+
const pair = await both('in1', 'in2', 1);
|
|
351
|
+
return pair && { type: 'mul', a: pair[0], b: pair[1] };
|
|
352
|
+
}
|
|
353
|
+
case 'subtract': {
|
|
354
|
+
const pair = await both('in1', 'in2', 0);
|
|
355
|
+
return pair && { type: 'add', a: pair[0], b: { type: 'mul', a: pair[1], b: { type: 'scalar', value: -1 } } };
|
|
356
|
+
}
|
|
357
|
+
case 'mix': {
|
|
358
|
+
// Foreground over background by the mix factor, so factor 1 gives `fg`.
|
|
359
|
+
const back = await this.operand(node, 'bg', graph, slot, 0), front = await this.operand(node, 'fg', graph, slot, 0), factor = await this.operand(node, 'mix', graph, slot, 0);
|
|
360
|
+
return back && front && factor && { type: 'mix', a: back, b: front, factor };
|
|
361
|
+
}
|
|
362
|
+
default:
|
|
363
|
+
this.skip(slot, `node ${node.category} has no node material form`);
|
|
364
|
+
return null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
/** An input as a value node, or null with a note when it cannot be one. */
|
|
368
|
+
async value(input, graph, slot) {
|
|
369
|
+
throwIfAborted(this.options.signal, F);
|
|
370
|
+
const found = this.follow(input, graph);
|
|
371
|
+
if (!found.node)
|
|
372
|
+
return this.constant(found.value, slot);
|
|
373
|
+
const { node } = found;
|
|
374
|
+
if (this.done.has(node))
|
|
375
|
+
return this.done.get(node);
|
|
376
|
+
if (this.path.has(node))
|
|
377
|
+
throw new LoaderError(F, 'range', `node ${node.name} is connected in a loop`);
|
|
378
|
+
if (this.path.size >= MAX_DEPTH)
|
|
379
|
+
throw new LoaderError(F, 'range', 'node connections run too deep');
|
|
380
|
+
this.path.add(node);
|
|
381
|
+
const built = await this.build(node, found.graph, slot);
|
|
382
|
+
this.path.delete(node);
|
|
383
|
+
this.done.set(node, built);
|
|
384
|
+
return built;
|
|
385
|
+
}
|
|
386
|
+
async normal(input, slot) {
|
|
387
|
+
const found = this.follow(input, null);
|
|
388
|
+
if (!found.node)
|
|
389
|
+
return null;
|
|
390
|
+
const { node, graph } = found;
|
|
391
|
+
if (node.category !== 'normalmap') {
|
|
392
|
+
this.skip(slot, `a normal from ${node.category} is not converted; connect a normalmap node`);
|
|
393
|
+
return null;
|
|
394
|
+
}
|
|
395
|
+
const map = node.inputs.in;
|
|
396
|
+
if (!map)
|
|
397
|
+
return null;
|
|
398
|
+
const texture = await this.value(map, graph, slot), scale = node.inputs.scale;
|
|
399
|
+
if (!texture)
|
|
400
|
+
return null;
|
|
401
|
+
const result = { type: 'normalMap', texture };
|
|
402
|
+
if (scale) {
|
|
403
|
+
const amount = await this.value(scale, graph, slot);
|
|
404
|
+
if (amount)
|
|
405
|
+
result.scale = amount;
|
|
406
|
+
}
|
|
407
|
+
return result;
|
|
408
|
+
}
|
|
409
|
+
/** A shader input, or its default when it is unset or would not convert. */
|
|
410
|
+
async slot(shader, [name, fallback]) {
|
|
411
|
+
const input = shader.inputs[name];
|
|
412
|
+
return (input && (await this.value(input, null, name))) ?? { type: 'scalar', value: fallback };
|
|
413
|
+
}
|
|
414
|
+
/** True when the input is unset or still a constant equal to `off`, so its lobe adds nothing. */
|
|
415
|
+
isOff(shader, name, off) {
|
|
416
|
+
const input = shader.inputs[name];
|
|
417
|
+
if (!input)
|
|
418
|
+
return true;
|
|
419
|
+
const connected = input.nodename ?? input.nodegraph ?? input.interfacename;
|
|
420
|
+
return connected === undefined && (input.value === undefined || input.value === off);
|
|
421
|
+
}
|
|
422
|
+
}
|
|
423
|
+
async function convert(doc, material, options) {
|
|
424
|
+
const { shader } = material;
|
|
425
|
+
if (!shader)
|
|
426
|
+
throw new LoaderError(F, 'syntax', `material ${material.name} has no surface shader`);
|
|
427
|
+
const map = surfaceOf(shader);
|
|
428
|
+
if (!map)
|
|
429
|
+
throw new LoaderError(F, 'unsupported', `surface shader ${shader.category} is not converted`);
|
|
430
|
+
const converter = new Converter(doc, options), [colorName, colorFallback] = map.color, colorInput = shader.inputs[colorName];
|
|
431
|
+
let color = (colorInput && (await converter.value(colorInput, null, colorName))) ?? {
|
|
432
|
+
type: 'color',
|
|
433
|
+
value: [...colorFallback, 1],
|
|
434
|
+
};
|
|
435
|
+
// A weight is a no-op only when it comes to 1; an unset weight takes the definition's default.
|
|
436
|
+
if (map.weight && (map.weight[1] !== 1 || !converter.isOff(shader, map.weight[0], 1)))
|
|
437
|
+
color = { type: 'mul', a: color, b: await converter.slot(shader, map.weight) };
|
|
438
|
+
const emit = {
|
|
439
|
+
type: 'emit',
|
|
440
|
+
color,
|
|
441
|
+
metalRough: {
|
|
442
|
+
type: 'metalRough',
|
|
443
|
+
roughness: await converter.slot(shader, map.roughness),
|
|
444
|
+
metal: await converter.slot(shader, map.metal),
|
|
445
|
+
},
|
|
446
|
+
};
|
|
447
|
+
const normal = shader.inputs[map.normal];
|
|
448
|
+
if (normal) {
|
|
449
|
+
const node = await converter.normal(normal, map.normal);
|
|
450
|
+
if (node)
|
|
451
|
+
emit.normal = node;
|
|
452
|
+
}
|
|
453
|
+
if (!converter.isOff(shader, map.coat[0], 0))
|
|
454
|
+
emit.clearcoat = {
|
|
455
|
+
type: 'clearcoat',
|
|
456
|
+
factor: await converter.slot(shader, map.coat),
|
|
457
|
+
roughness: await converter.slot(shader, map.coatRoughness),
|
|
458
|
+
};
|
|
459
|
+
if (!converter.isOff(shader, map.transmission[0], 0))
|
|
460
|
+
emit.transmission = {
|
|
461
|
+
type: 'transmission',
|
|
462
|
+
factor: await converter.slot(shader, map.transmission),
|
|
463
|
+
ior: await converter.slot(shader, map.ior),
|
|
464
|
+
};
|
|
465
|
+
const known = new Set([
|
|
466
|
+
colorName,
|
|
467
|
+
map.weight?.[0],
|
|
468
|
+
map.metal[0],
|
|
469
|
+
map.roughness[0],
|
|
470
|
+
map.normal,
|
|
471
|
+
map.coat[0],
|
|
472
|
+
map.coatRoughness[0],
|
|
473
|
+
map.transmission[0],
|
|
474
|
+
map.ior[0],
|
|
475
|
+
]);
|
|
476
|
+
for (const name of Object.keys(shader.inputs))
|
|
477
|
+
if (!known.has(name) && !IGNORED.has(name))
|
|
478
|
+
converter.skip(name, `${shader.category} input has no node material slot`);
|
|
479
|
+
return { graph: { nodes: [emit] }, skipped: converter.skipped };
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Reads a MaterialX document (1.38 and later): its nodes, node graphs, surface materials and looks. `toGraph` turns a
|
|
483
|
+
* `standard_surface`, `open_pbr_surface`, `gltf_pbr` or `UsdPreviewSurface` material into the object graph that
|
|
484
|
+
* `nodeMaterial()` of `@margoengine/materials` takes.
|
|
485
|
+
*
|
|
486
|
+
* @throws LoaderError code `header` when the root is not `<materialx>`, `syntax` for a bad value or a missing name,
|
|
487
|
+
* `unsupported` for a document of 1.37 or before.
|
|
488
|
+
*/
|
|
489
|
+
export function parseMaterialX(input, options = {}) {
|
|
490
|
+
const root = readXMLTree(toText(input, F), F, { external: options.external }).children[0];
|
|
491
|
+
if (root?.name !== 'materialx')
|
|
492
|
+
throw new LoaderError(F, 'header', `root element is <${root?.name}>, not <materialx>`);
|
|
493
|
+
const scope = scoped(root, {}), nodes = table(), graphs = table(), assignments = [], includes = [];
|
|
494
|
+
for (const element of root.children) {
|
|
495
|
+
const { name } = element;
|
|
496
|
+
if (name === 'material')
|
|
497
|
+
throw new LoaderError(F, 'unsupported', 'a <material> element is the form of 1.37 and before; upgrade the document');
|
|
498
|
+
if (name === 'nodegraph') {
|
|
499
|
+
const graph = readGraph(element, scope);
|
|
500
|
+
graphs[graph.name] = graph;
|
|
501
|
+
}
|
|
502
|
+
else if (name === 'include') {
|
|
503
|
+
if (element.attributes.href)
|
|
504
|
+
includes.push(element.attributes.href);
|
|
505
|
+
}
|
|
506
|
+
else if (name === 'look') {
|
|
507
|
+
for (const child of element.children)
|
|
508
|
+
if (child.name === 'materialassign') {
|
|
509
|
+
const { material, geom, collection } = child.attributes, assignment = { look: element.attributes.name ?? '', material: material ?? '' };
|
|
510
|
+
if (geom !== undefined)
|
|
511
|
+
assignment.geom = geom;
|
|
512
|
+
if (collection !== undefined)
|
|
513
|
+
assignment.collection = collection;
|
|
514
|
+
assignments.push(assignment);
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
else if (!NOT_NODES.has(name)) {
|
|
518
|
+
const node = readNode(element, scope);
|
|
519
|
+
nodes[node.name] = node;
|
|
520
|
+
}
|
|
521
|
+
}
|
|
522
|
+
const surface = (node) => {
|
|
523
|
+
const input = node.inputs.surfaceshader;
|
|
524
|
+
if (input?.nodename !== undefined)
|
|
525
|
+
return nodes[input.nodename] ?? null;
|
|
526
|
+
if (input?.nodegraph !== undefined) {
|
|
527
|
+
const graph = graphs[input.nodegraph], output = graph && (input.output === undefined ? Object.values(graph.outputs)[0] : graph.outputs[input.output]);
|
|
528
|
+
return (output?.nodename !== undefined && graph?.nodes[output.nodename]) || null;
|
|
529
|
+
}
|
|
530
|
+
return null;
|
|
531
|
+
};
|
|
532
|
+
const materials = Object.values(nodes)
|
|
533
|
+
.filter((node) => node.category === 'surfacematerial')
|
|
534
|
+
.map((node) => ({ name: node.name, shader: surface(node) }));
|
|
535
|
+
const doc = materialXDocument({
|
|
536
|
+
version: root.attributes.version ?? '',
|
|
537
|
+
nodes,
|
|
538
|
+
graphs,
|
|
539
|
+
materials,
|
|
540
|
+
assignments,
|
|
541
|
+
includes,
|
|
542
|
+
});
|
|
543
|
+
if (root.attributes.colorspace !== undefined)
|
|
544
|
+
doc.colorspace = root.attributes.colorspace;
|
|
545
|
+
return doc;
|
|
546
|
+
}
|
|
547
|
+
/** A document from parts, for a network that came from elsewhere, such as a USD stage. `nodes` have a null prototype. */
|
|
548
|
+
export function materialXDocument(parts) {
|
|
549
|
+
const { materials } = parts, doc = {
|
|
550
|
+
version: '',
|
|
551
|
+
graphs: table(),
|
|
552
|
+
assignments: [],
|
|
553
|
+
includes: [],
|
|
554
|
+
...parts,
|
|
555
|
+
toGraph(name, options = {}) {
|
|
556
|
+
const material = name === undefined ? materials[0] : materials.find((item) => item.name === name);
|
|
557
|
+
if (!material)
|
|
558
|
+
return Promise.reject(new LoaderError(F, 'range', `no material ${name ?? 'in the document'}`));
|
|
559
|
+
return convert(doc, material, options);
|
|
560
|
+
},
|
|
561
|
+
};
|
|
562
|
+
return doc;
|
|
563
|
+
}
|