babylonjs-serializers 9.18.1 → 9.19.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/babylon.threemfSerializer.js.map +1 -1
- package/babylon.threemfSerializer.min.js.map +1 -1
- package/babylonjs.serializers.d.ts +136 -95
- package/babylonjs.serializers.js.map +1 -1
- package/babylonjs.serializers.min.js.map +1 -1
- package/babylonjs.serializers.module.d.ts +272 -190
- package/package.json +3 -3
|
@@ -3972,228 +3972,269 @@ import { Matrix3d, ThreeMfModel, ThreeMfObject } from "babylonjs-serializers/3MF
|
|
|
3972
3972
|
import { I3mfBaseMaterials, I3mfModel, I3mfObject, I3mfTriangle, I3mfVertex, ST_ResourceID, ST_ResourceIndex, ST_Unit, ST_ObjectType } from "babylonjs-serializers/3MF/core/model/3mf.interfaces";
|
|
3973
3973
|
import { I3mfDocument, I3mfContentType, I3mfRelationship } from "babylonjs-serializers/3MF/core/model/3mf.opc.interfaces";
|
|
3974
3974
|
import { I3mfRGBAColor, I3mfVertexData } from "babylonjs-serializers/3MF/core/model/3mf.types";
|
|
3975
|
+
/**
|
|
3976
|
+
* Handler invoked for every vertex generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
3977
|
+
*/
|
|
3975
3978
|
export type VertexHandler = (vertex: I3mfVertex) => I3mfVertex;
|
|
3979
|
+
/**
|
|
3980
|
+
* Handler invoked for every triangle generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
3981
|
+
*/
|
|
3976
3982
|
export type TriangleHandler = (triangle: I3mfTriangle) => I3mfTriangle;
|
|
3977
|
-
/**
|
|
3983
|
+
/**
|
|
3984
|
+
* Fluent builder for a 3MF object resource.
|
|
3985
|
+
* An object is the base resource of a 3MF model and is either a mesh or a set of components.
|
|
3986
|
+
*/
|
|
3978
3987
|
export class ThreeMfObjectBuilder {
|
|
3979
3988
|
/**
|
|
3980
|
-
*
|
|
3989
|
+
* The 3MF object resource currently being built.
|
|
3981
3990
|
*/
|
|
3982
3991
|
protected _object: ThreeMfObject;
|
|
3983
3992
|
/**
|
|
3984
|
-
*
|
|
3985
|
-
* @param id
|
|
3986
|
-
* @param type
|
|
3993
|
+
* Creates a new object builder.
|
|
3994
|
+
* @param id The unique resource id of the object within the model.
|
|
3995
|
+
* @param type The 3MF object type (model, support, solidsupport, surface or other).
|
|
3987
3996
|
*/
|
|
3988
3997
|
constructor(id: ST_ResourceID, type: ST_ObjectType);
|
|
3989
3998
|
/**
|
|
3990
|
-
*
|
|
3991
|
-
* @param name
|
|
3992
|
-
* @returns
|
|
3999
|
+
* Sets the human readable name of the object.
|
|
4000
|
+
* @param name The name to assign to the object.
|
|
4001
|
+
* @returns This builder, to allow chaining.
|
|
3993
4002
|
*/
|
|
3994
4003
|
withName(name: string): ThreeMfObjectBuilder;
|
|
3995
4004
|
/**
|
|
3996
|
-
*
|
|
3997
|
-
* @param thumbnail
|
|
3998
|
-
* @returns
|
|
4005
|
+
* Sets the thumbnail of the object.
|
|
4006
|
+
* @param thumbnail The package relative path of the thumbnail part.
|
|
4007
|
+
* @returns This builder, to allow chaining.
|
|
3999
4008
|
*/
|
|
4000
4009
|
withThumbnail(thumbnail: string): ThreeMfObjectBuilder;
|
|
4001
4010
|
/**
|
|
4002
|
-
*
|
|
4003
|
-
* @param id
|
|
4004
|
-
* @param index
|
|
4005
|
-
* @returns
|
|
4011
|
+
* Assigns the property resource used by the object.
|
|
4012
|
+
* @param id The resource id of the property group (for example a base materials group).
|
|
4013
|
+
* @param index The zero based index of the property within the group. Defaults to 0.
|
|
4014
|
+
* @returns This builder, to allow chaining.
|
|
4006
4015
|
*/
|
|
4007
4016
|
withProperty(id: ST_ResourceIndex, index?: number): ThreeMfObjectBuilder;
|
|
4008
4017
|
/**
|
|
4009
|
-
*
|
|
4010
|
-
* @returns
|
|
4018
|
+
* Returns the object that has been built.
|
|
4019
|
+
* @returns The built 3MF object resource.
|
|
4011
4020
|
*/
|
|
4012
4021
|
build(): I3mfObject;
|
|
4013
4022
|
/**
|
|
4014
|
-
*
|
|
4015
|
-
* @param id
|
|
4016
|
-
* @param type
|
|
4023
|
+
* Discards the current object and starts building a new one.
|
|
4024
|
+
* @param id The unique resource id of the new object.
|
|
4025
|
+
* @param type The 3MF object type of the new object.
|
|
4017
4026
|
*/
|
|
4018
4027
|
reset(id: ST_ResourceID, type: ST_ObjectType): void;
|
|
4019
4028
|
}
|
|
4020
4029
|
/**
|
|
4021
|
-
*
|
|
4030
|
+
* Fluent builder for a 3MF object made of components.
|
|
4031
|
+
* A components object references other objects instead of defining its own geometry.
|
|
4022
4032
|
*/
|
|
4023
4033
|
export class ThreeMfComponentsBuilder extends ThreeMfObjectBuilder {
|
|
4024
4034
|
/**
|
|
4025
|
-
*
|
|
4026
|
-
* @param id
|
|
4027
|
-
* @param type
|
|
4035
|
+
* Creates a new components object builder.
|
|
4036
|
+
* @param id The unique resource id of the object within the model.
|
|
4037
|
+
* @param type The 3MF object type. Defaults to `ST_ObjectType.model`.
|
|
4028
4038
|
*/
|
|
4029
4039
|
constructor(id: ST_ResourceID, type?: ST_ObjectType);
|
|
4030
4040
|
/**
|
|
4031
|
-
*
|
|
4032
|
-
* @param id
|
|
4033
|
-
* @param t
|
|
4034
|
-
* @returns
|
|
4041
|
+
* Adds a component referencing another object resource.
|
|
4042
|
+
* @param id The resource id of the referenced object.
|
|
4043
|
+
* @param t The optional transform applied to the referenced object.
|
|
4044
|
+
* @returns This builder, to allow chaining.
|
|
4035
4045
|
*/
|
|
4036
4046
|
withComponent(id: ST_ResourceID, t?: Matrix3d): ThreeMfComponentsBuilder;
|
|
4037
4047
|
}
|
|
4038
4048
|
/**
|
|
4039
|
-
*
|
|
4049
|
+
* Fluent builder for a 3MF object holding a mesh.
|
|
4050
|
+
* Vertices and triangles are generated from Babylon vertex data and can be post processed through handlers.
|
|
4040
4051
|
*/
|
|
4041
4052
|
export class ThreeMfMeshBuilder extends ThreeMfObjectBuilder {
|
|
4042
4053
|
/**
|
|
4043
|
-
*
|
|
4054
|
+
* Optional handler invoked for every vertex before it is added to the mesh.
|
|
4044
4055
|
*/
|
|
4045
4056
|
_vh?: VertexHandler;
|
|
4046
4057
|
/**
|
|
4047
|
-
*
|
|
4058
|
+
* Optional handler invoked for every triangle before it is added to the mesh.
|
|
4048
4059
|
*/
|
|
4049
4060
|
_th?: TriangleHandler;
|
|
4050
4061
|
/**
|
|
4051
|
-
*
|
|
4052
|
-
* @param id
|
|
4062
|
+
* Creates a new mesh object builder.
|
|
4063
|
+
* @param id The unique resource id of the object within the model.
|
|
4053
4064
|
*/
|
|
4054
4065
|
constructor(id: ST_ResourceID);
|
|
4055
4066
|
/**
|
|
4056
|
-
*
|
|
4057
|
-
* @param vertex
|
|
4058
|
-
* @param triangle
|
|
4059
|
-
* @returns
|
|
4067
|
+
* Registers the handlers used to post process the generated geometry.
|
|
4068
|
+
* @param vertex The handler invoked for every generated vertex.
|
|
4069
|
+
* @param triangle The optional handler invoked for every generated triangle.
|
|
4070
|
+
* @returns This builder, to allow chaining.
|
|
4060
4071
|
*/
|
|
4061
4072
|
withPostProcessHandlers(vertex: VertexHandler, triangle?: TriangleHandler): ThreeMfMeshBuilder;
|
|
4062
4073
|
/**
|
|
4063
|
-
*
|
|
4064
|
-
* @param data
|
|
4065
|
-
* @returns
|
|
4074
|
+
* Builds the mesh content of the object from the provided vertex data.
|
|
4075
|
+
* @param data The positions and indices used to generate the mesh.
|
|
4076
|
+
* @returns This builder, to allow chaining.
|
|
4066
4077
|
*/
|
|
4067
4078
|
withData(data: I3mfVertexData): ThreeMfMeshBuilder;
|
|
4068
4079
|
/**
|
|
4069
|
-
*
|
|
4070
|
-
* @param id
|
|
4071
|
-
* @param i
|
|
4072
|
-
* @returns
|
|
4080
|
+
* Assigns the material used by the mesh.
|
|
4081
|
+
* @param id The resource id of the base materials group.
|
|
4082
|
+
* @param i The zero based index of the material within the group.
|
|
4083
|
+
* @returns This builder, to allow chaining.
|
|
4073
4084
|
*/
|
|
4074
4085
|
withMaterial(id: ST_ResourceID, i: number): ThreeMfMeshBuilder;
|
|
4075
4086
|
/**
|
|
4076
|
-
*
|
|
4077
|
-
* @param data
|
|
4078
|
-
* @returns
|
|
4087
|
+
* Converts vertex data into a 3MF mesh.
|
|
4088
|
+
* @param data The positions and indices used to generate the mesh.
|
|
4089
|
+
* @returns The generated 3MF mesh.
|
|
4079
4090
|
*/
|
|
4080
4091
|
private _buildMesh;
|
|
4092
|
+
/**
|
|
4093
|
+
* Converts a flat position array into a 3MF vertex list, applying the vertex handler when one is registered.
|
|
4094
|
+
* @param p The flat array of x, y and z positions.
|
|
4095
|
+
* @returns The generated 3MF vertex list.
|
|
4096
|
+
*/
|
|
4081
4097
|
private _buildVertices;
|
|
4098
|
+
/**
|
|
4099
|
+
* Converts a flat index array into a 3MF triangle list, applying the triangle handler when one is registered.
|
|
4100
|
+
* @param indice The flat array of vertex indices, three per triangle.
|
|
4101
|
+
* @returns The generated 3MF triangle list.
|
|
4102
|
+
*/
|
|
4082
4103
|
private _buildTriangle;
|
|
4083
4104
|
}
|
|
4084
4105
|
/**
|
|
4085
|
-
*
|
|
4106
|
+
* Fluent builder for a 3MF base materials resource.
|
|
4107
|
+
* Colors are stored as sRGB hexadecimal strings as required by the 3MF specification.
|
|
4086
4108
|
*/
|
|
4087
4109
|
export class ThreeMfMaterialBuilder {
|
|
4088
4110
|
private _m;
|
|
4111
|
+
/**
|
|
4112
|
+
* Creates a new base materials builder.
|
|
4113
|
+
* @param id The unique resource id of the base materials group within the model.
|
|
4114
|
+
*/
|
|
4089
4115
|
constructor(id: ST_ResourceID);
|
|
4090
4116
|
/**
|
|
4091
|
-
*
|
|
4092
|
-
* @param name
|
|
4093
|
-
* @param color
|
|
4094
|
-
* @returns
|
|
4117
|
+
* Adds a named color to the group, or updates it when the name already exists.
|
|
4118
|
+
* @param name The name of the material. The lookup is case insensitive.
|
|
4119
|
+
* @param color The linear RGBA color, converted to an sRGB hexadecimal string.
|
|
4120
|
+
* @returns This builder, to allow chaining.
|
|
4095
4121
|
*/
|
|
4096
4122
|
withColor(name: string, color: I3mfRGBAColor): ThreeMfMaterialBuilder;
|
|
4097
4123
|
/**
|
|
4098
|
-
*
|
|
4099
|
-
* @returns
|
|
4124
|
+
* Returns the base materials group that has been built.
|
|
4125
|
+
* @returns The built base materials resource.
|
|
4100
4126
|
*/
|
|
4101
4127
|
build(): I3mfBaseMaterials;
|
|
4128
|
+
/**
|
|
4129
|
+
* Converts a linear color into the sRGB hexadecimal string used by 3MF.
|
|
4130
|
+
* @param c The linear color to convert. The alpha channel is optional.
|
|
4131
|
+
* @returns The color as `#RRGGBB`, or `#RRGGBBAA` when an alpha channel is provided.
|
|
4132
|
+
*/
|
|
4102
4133
|
private _rgbaToHex;
|
|
4103
4134
|
}
|
|
4104
4135
|
/**
|
|
4105
|
-
*
|
|
4136
|
+
* Fluent builder for a 3MF model, the root part of a 3MF document.
|
|
4137
|
+
* It aggregates the resources (materials, meshes and components) and the build items that reference them.
|
|
4106
4138
|
*/
|
|
4107
4139
|
export class ThreeMfModelBuilder {
|
|
4108
4140
|
/**
|
|
4109
|
-
*
|
|
4141
|
+
* The lower cased set of the metadata names defined by the 3MF specification.
|
|
4110
4142
|
*/
|
|
4111
4143
|
static KnownMetaSet: Set<string>;
|
|
4112
4144
|
/**
|
|
4113
|
-
*
|
|
4145
|
+
* The 3MF model currently being built.
|
|
4114
4146
|
*/
|
|
4115
4147
|
_model: ThreeMfModel;
|
|
4116
4148
|
/**
|
|
4117
|
-
*
|
|
4149
|
+
* The object resources added to the model, indexed by resource id.
|
|
4118
4150
|
*/
|
|
4119
4151
|
_objects: Map<string, I3mfObject>;
|
|
4120
4152
|
/**
|
|
4121
|
-
*
|
|
4122
|
-
* @param name
|
|
4123
|
-
* @param value
|
|
4124
|
-
* @param preserve
|
|
4125
|
-
* @param type
|
|
4126
|
-
* @returns
|
|
4153
|
+
* Adds a metadata entry to the model.
|
|
4154
|
+
* @param name The metadata name. Names outside of the 3MF specification must be namespace qualified.
|
|
4155
|
+
* @param value The metadata value.
|
|
4156
|
+
* @param preserve Whether consumers must preserve this entry when editing the document.
|
|
4157
|
+
* @param type The XML schema type of the value. Defaults to `xs:string`.
|
|
4158
|
+
* @returns This builder, to allow chaining.
|
|
4127
4159
|
*/
|
|
4128
4160
|
withMetaData(name: string, value: string, preserve?: boolean, type?: string): ThreeMfModelBuilder;
|
|
4129
4161
|
/**
|
|
4130
|
-
*
|
|
4131
|
-
* @param material
|
|
4132
|
-
* @returns
|
|
4162
|
+
* Adds a base materials group to the model resources.
|
|
4163
|
+
* @param material The base materials resource, or a builder that produces one.
|
|
4164
|
+
* @returns This builder, to allow chaining.
|
|
4133
4165
|
*/
|
|
4134
4166
|
withMaterial(material: I3mfBaseMaterials | ThreeMfMaterialBuilder): ThreeMfModelBuilder;
|
|
4135
4167
|
/**
|
|
4136
|
-
*
|
|
4137
|
-
* @param object
|
|
4138
|
-
* @returns
|
|
4168
|
+
* Adds a mesh object to the model resources.
|
|
4169
|
+
* @param object The object resource, or a builder that produces one.
|
|
4170
|
+
* @returns This builder, to allow chaining.
|
|
4139
4171
|
*/
|
|
4140
4172
|
withMesh(object: I3mfObject | ThreeMfMeshBuilder): ThreeMfModelBuilder;
|
|
4141
4173
|
/**
|
|
4142
|
-
*
|
|
4143
|
-
* @param components
|
|
4144
|
-
* @returns
|
|
4174
|
+
* Adds a components object to the model resources.
|
|
4175
|
+
* @param components The object resource, or a builder that produces one.
|
|
4176
|
+
* @returns This builder, to allow chaining.
|
|
4145
4177
|
*/
|
|
4146
4178
|
withComponents(components: I3mfObject | ThreeMfComponentsBuilder): ThreeMfModelBuilder;
|
|
4147
4179
|
/**
|
|
4148
|
-
*
|
|
4149
|
-
* @param objectid
|
|
4150
|
-
* @param transform
|
|
4151
|
-
* @param partnumber
|
|
4152
|
-
* @returns
|
|
4180
|
+
* Adds a build item, which places an object resource in the build plate.
|
|
4181
|
+
* @param objectid The resource id of the object to place.
|
|
4182
|
+
* @param transform The optional transform applied to the object.
|
|
4183
|
+
* @param partnumber The optional part number identifying the produced part.
|
|
4184
|
+
* @returns This builder, to allow chaining.
|
|
4153
4185
|
*/
|
|
4154
4186
|
withBuild(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string): ThreeMfModelBuilder;
|
|
4155
4187
|
/**
|
|
4156
|
-
*
|
|
4157
|
-
* @param unit
|
|
4158
|
-
* @returns
|
|
4188
|
+
* Sets the unit in which the model coordinates are expressed.
|
|
4189
|
+
* @param unit The 3MF unit (micron, millimeter, centimeter, inch, foot or meter).
|
|
4190
|
+
* @returns This builder, to allow chaining.
|
|
4159
4191
|
*/
|
|
4160
4192
|
withUnit(unit: ST_Unit): ThreeMfModelBuilder;
|
|
4161
4193
|
/**
|
|
4162
|
-
*
|
|
4163
|
-
* @returns
|
|
4194
|
+
* Discards the current model and starts building a new one.
|
|
4195
|
+
* @returns This builder, to allow chaining.
|
|
4164
4196
|
*/
|
|
4165
4197
|
reset(): ThreeMfModelBuilder;
|
|
4166
4198
|
/**
|
|
4167
|
-
*
|
|
4168
|
-
* @returns
|
|
4199
|
+
* Validates and returns the model that has been built.
|
|
4200
|
+
* @returns The built 3MF model.
|
|
4201
|
+
* @throws When the model has no object resource or no build item.
|
|
4169
4202
|
*/
|
|
4170
4203
|
build(): ThreeMfModel;
|
|
4171
4204
|
}
|
|
4172
4205
|
/**
|
|
4173
|
-
*
|
|
4206
|
+
* Fluent builder for a 3MF document, the OPC package that wraps the model.
|
|
4207
|
+
* It gathers the content types, the relationships and the model part.
|
|
4174
4208
|
*/
|
|
4175
4209
|
export class ThreeMfDocumentBuilder {
|
|
4176
4210
|
private _cts?;
|
|
4177
4211
|
private _rs?;
|
|
4178
4212
|
private _m?;
|
|
4179
4213
|
/**
|
|
4180
|
-
*
|
|
4181
|
-
* @param type
|
|
4182
|
-
* @returns
|
|
4214
|
+
* Declares an OPC content type. Duplicate declarations are ignored.
|
|
4215
|
+
* @param type The extension to content type mapping to declare.
|
|
4216
|
+
* @returns This builder, to allow chaining.
|
|
4183
4217
|
*/
|
|
4184
4218
|
withContentType(type: I3mfContentType): ThreeMfDocumentBuilder;
|
|
4185
4219
|
/**
|
|
4186
|
-
*
|
|
4187
|
-
*
|
|
4188
|
-
* @
|
|
4220
|
+
* Adds an OPC relationship and ensures the relationships content type is declared.
|
|
4221
|
+
* Relationships with an already registered id are ignored.
|
|
4222
|
+
* @param rel The relationship to add.
|
|
4223
|
+
* @returns This builder, to allow chaining.
|
|
4189
4224
|
*/
|
|
4190
4225
|
withRelationship(rel: I3mfRelationship): ThreeMfDocumentBuilder;
|
|
4191
4226
|
/**
|
|
4192
|
-
*
|
|
4193
|
-
* @param m
|
|
4194
|
-
* @returns
|
|
4227
|
+
* Sets the model part of the document and ensures the model content type is declared.
|
|
4228
|
+
* @param m The model resource, or a builder that produces one.
|
|
4229
|
+
* @returns This builder, to allow chaining.
|
|
4195
4230
|
*/
|
|
4196
4231
|
withModel(m: I3mfModel | ThreeMfModelBuilder): ThreeMfDocumentBuilder;
|
|
4232
|
+
/**
|
|
4233
|
+
* Validates and returns the document that has been built.
|
|
4234
|
+
* A default relationship pointing at the model part is generated when none was provided.
|
|
4235
|
+
* @returns The built 3MF document.
|
|
4236
|
+
* @throws When no model has been set.
|
|
4237
|
+
*/
|
|
4197
4238
|
build(): I3mfDocument;
|
|
4198
4239
|
}
|
|
4199
4240
|
|
|
@@ -7711,228 +7752,269 @@ declare namespace BABYLON {
|
|
|
7711
7752
|
}
|
|
7712
7753
|
|
|
7713
7754
|
|
|
7755
|
+
/**
|
|
7756
|
+
* Handler invoked for every vertex generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
7757
|
+
*/
|
|
7714
7758
|
export type VertexHandler = (vertex: I3mfVertex) => I3mfVertex;
|
|
7759
|
+
/**
|
|
7760
|
+
* Handler invoked for every triangle generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
7761
|
+
*/
|
|
7715
7762
|
export type TriangleHandler = (triangle: I3mfTriangle) => I3mfTriangle;
|
|
7716
|
-
/**
|
|
7763
|
+
/**
|
|
7764
|
+
* Fluent builder for a 3MF object resource.
|
|
7765
|
+
* An object is the base resource of a 3MF model and is either a mesh or a set of components.
|
|
7766
|
+
*/
|
|
7717
7767
|
export class ThreeMfObjectBuilder {
|
|
7718
7768
|
/**
|
|
7719
|
-
*
|
|
7769
|
+
* The 3MF object resource currently being built.
|
|
7720
7770
|
*/
|
|
7721
7771
|
protected _object: ThreeMfObject;
|
|
7722
7772
|
/**
|
|
7723
|
-
*
|
|
7724
|
-
* @param id
|
|
7725
|
-
* @param type
|
|
7773
|
+
* Creates a new object builder.
|
|
7774
|
+
* @param id The unique resource id of the object within the model.
|
|
7775
|
+
* @param type The 3MF object type (model, support, solidsupport, surface or other).
|
|
7726
7776
|
*/
|
|
7727
7777
|
constructor(id: ST_ResourceID, type: ST_ObjectType);
|
|
7728
7778
|
/**
|
|
7729
|
-
*
|
|
7730
|
-
* @param name
|
|
7731
|
-
* @returns
|
|
7779
|
+
* Sets the human readable name of the object.
|
|
7780
|
+
* @param name The name to assign to the object.
|
|
7781
|
+
* @returns This builder, to allow chaining.
|
|
7732
7782
|
*/
|
|
7733
7783
|
withName(name: string): ThreeMfObjectBuilder;
|
|
7734
7784
|
/**
|
|
7735
|
-
*
|
|
7736
|
-
* @param thumbnail
|
|
7737
|
-
* @returns
|
|
7785
|
+
* Sets the thumbnail of the object.
|
|
7786
|
+
* @param thumbnail The package relative path of the thumbnail part.
|
|
7787
|
+
* @returns This builder, to allow chaining.
|
|
7738
7788
|
*/
|
|
7739
7789
|
withThumbnail(thumbnail: string): ThreeMfObjectBuilder;
|
|
7740
7790
|
/**
|
|
7741
|
-
*
|
|
7742
|
-
* @param id
|
|
7743
|
-
* @param index
|
|
7744
|
-
* @returns
|
|
7791
|
+
* Assigns the property resource used by the object.
|
|
7792
|
+
* @param id The resource id of the property group (for example a base materials group).
|
|
7793
|
+
* @param index The zero based index of the property within the group. Defaults to 0.
|
|
7794
|
+
* @returns This builder, to allow chaining.
|
|
7745
7795
|
*/
|
|
7746
7796
|
withProperty(id: ST_ResourceIndex, index?: number): ThreeMfObjectBuilder;
|
|
7747
7797
|
/**
|
|
7748
|
-
*
|
|
7749
|
-
* @returns
|
|
7798
|
+
* Returns the object that has been built.
|
|
7799
|
+
* @returns The built 3MF object resource.
|
|
7750
7800
|
*/
|
|
7751
7801
|
build(): I3mfObject;
|
|
7752
7802
|
/**
|
|
7753
|
-
*
|
|
7754
|
-
* @param id
|
|
7755
|
-
* @param type
|
|
7803
|
+
* Discards the current object and starts building a new one.
|
|
7804
|
+
* @param id The unique resource id of the new object.
|
|
7805
|
+
* @param type The 3MF object type of the new object.
|
|
7756
7806
|
*/
|
|
7757
7807
|
reset(id: ST_ResourceID, type: ST_ObjectType): void;
|
|
7758
7808
|
}
|
|
7759
7809
|
/**
|
|
7760
|
-
*
|
|
7810
|
+
* Fluent builder for a 3MF object made of components.
|
|
7811
|
+
* A components object references other objects instead of defining its own geometry.
|
|
7761
7812
|
*/
|
|
7762
7813
|
export class ThreeMfComponentsBuilder extends ThreeMfObjectBuilder {
|
|
7763
7814
|
/**
|
|
7764
|
-
*
|
|
7765
|
-
* @param id
|
|
7766
|
-
* @param type
|
|
7815
|
+
* Creates a new components object builder.
|
|
7816
|
+
* @param id The unique resource id of the object within the model.
|
|
7817
|
+
* @param type The 3MF object type. Defaults to `ST_ObjectType.model`.
|
|
7767
7818
|
*/
|
|
7768
7819
|
constructor(id: ST_ResourceID, type?: ST_ObjectType);
|
|
7769
7820
|
/**
|
|
7770
|
-
*
|
|
7771
|
-
* @param id
|
|
7772
|
-
* @param t
|
|
7773
|
-
* @returns
|
|
7821
|
+
* Adds a component referencing another object resource.
|
|
7822
|
+
* @param id The resource id of the referenced object.
|
|
7823
|
+
* @param t The optional transform applied to the referenced object.
|
|
7824
|
+
* @returns This builder, to allow chaining.
|
|
7774
7825
|
*/
|
|
7775
7826
|
withComponent(id: ST_ResourceID, t?: Matrix3d): ThreeMfComponentsBuilder;
|
|
7776
7827
|
}
|
|
7777
7828
|
/**
|
|
7778
|
-
*
|
|
7829
|
+
* Fluent builder for a 3MF object holding a mesh.
|
|
7830
|
+
* Vertices and triangles are generated from Babylon vertex data and can be post processed through handlers.
|
|
7779
7831
|
*/
|
|
7780
7832
|
export class ThreeMfMeshBuilder extends ThreeMfObjectBuilder {
|
|
7781
7833
|
/**
|
|
7782
|
-
*
|
|
7834
|
+
* Optional handler invoked for every vertex before it is added to the mesh.
|
|
7783
7835
|
*/
|
|
7784
7836
|
_vh?: VertexHandler;
|
|
7785
7837
|
/**
|
|
7786
|
-
*
|
|
7838
|
+
* Optional handler invoked for every triangle before it is added to the mesh.
|
|
7787
7839
|
*/
|
|
7788
7840
|
_th?: TriangleHandler;
|
|
7789
7841
|
/**
|
|
7790
|
-
*
|
|
7791
|
-
* @param id
|
|
7842
|
+
* Creates a new mesh object builder.
|
|
7843
|
+
* @param id The unique resource id of the object within the model.
|
|
7792
7844
|
*/
|
|
7793
7845
|
constructor(id: ST_ResourceID);
|
|
7794
7846
|
/**
|
|
7795
|
-
*
|
|
7796
|
-
* @param vertex
|
|
7797
|
-
* @param triangle
|
|
7798
|
-
* @returns
|
|
7847
|
+
* Registers the handlers used to post process the generated geometry.
|
|
7848
|
+
* @param vertex The handler invoked for every generated vertex.
|
|
7849
|
+
* @param triangle The optional handler invoked for every generated triangle.
|
|
7850
|
+
* @returns This builder, to allow chaining.
|
|
7799
7851
|
*/
|
|
7800
7852
|
withPostProcessHandlers(vertex: VertexHandler, triangle?: TriangleHandler): ThreeMfMeshBuilder;
|
|
7801
7853
|
/**
|
|
7802
|
-
*
|
|
7803
|
-
* @param data
|
|
7804
|
-
* @returns
|
|
7854
|
+
* Builds the mesh content of the object from the provided vertex data.
|
|
7855
|
+
* @param data The positions and indices used to generate the mesh.
|
|
7856
|
+
* @returns This builder, to allow chaining.
|
|
7805
7857
|
*/
|
|
7806
7858
|
withData(data: I3mfVertexData): ThreeMfMeshBuilder;
|
|
7807
7859
|
/**
|
|
7808
|
-
*
|
|
7809
|
-
* @param id
|
|
7810
|
-
* @param i
|
|
7811
|
-
* @returns
|
|
7860
|
+
* Assigns the material used by the mesh.
|
|
7861
|
+
* @param id The resource id of the base materials group.
|
|
7862
|
+
* @param i The zero based index of the material within the group.
|
|
7863
|
+
* @returns This builder, to allow chaining.
|
|
7812
7864
|
*/
|
|
7813
7865
|
withMaterial(id: ST_ResourceID, i: number): ThreeMfMeshBuilder;
|
|
7814
7866
|
/**
|
|
7815
|
-
*
|
|
7816
|
-
* @param data
|
|
7817
|
-
* @returns
|
|
7867
|
+
* Converts vertex data into a 3MF mesh.
|
|
7868
|
+
* @param data The positions and indices used to generate the mesh.
|
|
7869
|
+
* @returns The generated 3MF mesh.
|
|
7818
7870
|
*/
|
|
7819
7871
|
private _buildMesh;
|
|
7872
|
+
/**
|
|
7873
|
+
* Converts a flat position array into a 3MF vertex list, applying the vertex handler when one is registered.
|
|
7874
|
+
* @param p The flat array of x, y and z positions.
|
|
7875
|
+
* @returns The generated 3MF vertex list.
|
|
7876
|
+
*/
|
|
7820
7877
|
private _buildVertices;
|
|
7878
|
+
/**
|
|
7879
|
+
* Converts a flat index array into a 3MF triangle list, applying the triangle handler when one is registered.
|
|
7880
|
+
* @param indice The flat array of vertex indices, three per triangle.
|
|
7881
|
+
* @returns The generated 3MF triangle list.
|
|
7882
|
+
*/
|
|
7821
7883
|
private _buildTriangle;
|
|
7822
7884
|
}
|
|
7823
7885
|
/**
|
|
7824
|
-
*
|
|
7886
|
+
* Fluent builder for a 3MF base materials resource.
|
|
7887
|
+
* Colors are stored as sRGB hexadecimal strings as required by the 3MF specification.
|
|
7825
7888
|
*/
|
|
7826
7889
|
export class ThreeMfMaterialBuilder {
|
|
7827
7890
|
private _m;
|
|
7891
|
+
/**
|
|
7892
|
+
* Creates a new base materials builder.
|
|
7893
|
+
* @param id The unique resource id of the base materials group within the model.
|
|
7894
|
+
*/
|
|
7828
7895
|
constructor(id: ST_ResourceID);
|
|
7829
7896
|
/**
|
|
7830
|
-
*
|
|
7831
|
-
* @param name
|
|
7832
|
-
* @param color
|
|
7833
|
-
* @returns
|
|
7897
|
+
* Adds a named color to the group, or updates it when the name already exists.
|
|
7898
|
+
* @param name The name of the material. The lookup is case insensitive.
|
|
7899
|
+
* @param color The linear RGBA color, converted to an sRGB hexadecimal string.
|
|
7900
|
+
* @returns This builder, to allow chaining.
|
|
7834
7901
|
*/
|
|
7835
7902
|
withColor(name: string, color: I3mfRGBAColor): ThreeMfMaterialBuilder;
|
|
7836
7903
|
/**
|
|
7837
|
-
*
|
|
7838
|
-
* @returns
|
|
7904
|
+
* Returns the base materials group that has been built.
|
|
7905
|
+
* @returns The built base materials resource.
|
|
7839
7906
|
*/
|
|
7840
7907
|
build(): I3mfBaseMaterials;
|
|
7908
|
+
/**
|
|
7909
|
+
* Converts a linear color into the sRGB hexadecimal string used by 3MF.
|
|
7910
|
+
* @param c The linear color to convert. The alpha channel is optional.
|
|
7911
|
+
* @returns The color as `#RRGGBB`, or `#RRGGBBAA` when an alpha channel is provided.
|
|
7912
|
+
*/
|
|
7841
7913
|
private _rgbaToHex;
|
|
7842
7914
|
}
|
|
7843
7915
|
/**
|
|
7844
|
-
*
|
|
7916
|
+
* Fluent builder for a 3MF model, the root part of a 3MF document.
|
|
7917
|
+
* It aggregates the resources (materials, meshes and components) and the build items that reference them.
|
|
7845
7918
|
*/
|
|
7846
7919
|
export class ThreeMfModelBuilder {
|
|
7847
7920
|
/**
|
|
7848
|
-
*
|
|
7921
|
+
* The lower cased set of the metadata names defined by the 3MF specification.
|
|
7849
7922
|
*/
|
|
7850
7923
|
static KnownMetaSet: Set<string>;
|
|
7851
7924
|
/**
|
|
7852
|
-
*
|
|
7925
|
+
* The 3MF model currently being built.
|
|
7853
7926
|
*/
|
|
7854
7927
|
_model: ThreeMfModel;
|
|
7855
7928
|
/**
|
|
7856
|
-
*
|
|
7929
|
+
* The object resources added to the model, indexed by resource id.
|
|
7857
7930
|
*/
|
|
7858
7931
|
_objects: Map<string, I3mfObject>;
|
|
7859
7932
|
/**
|
|
7860
|
-
*
|
|
7861
|
-
* @param name
|
|
7862
|
-
* @param value
|
|
7863
|
-
* @param preserve
|
|
7864
|
-
* @param type
|
|
7865
|
-
* @returns
|
|
7933
|
+
* Adds a metadata entry to the model.
|
|
7934
|
+
* @param name The metadata name. Names outside of the 3MF specification must be namespace qualified.
|
|
7935
|
+
* @param value The metadata value.
|
|
7936
|
+
* @param preserve Whether consumers must preserve this entry when editing the document.
|
|
7937
|
+
* @param type The XML schema type of the value. Defaults to `xs:string`.
|
|
7938
|
+
* @returns This builder, to allow chaining.
|
|
7866
7939
|
*/
|
|
7867
7940
|
withMetaData(name: string, value: string, preserve?: boolean, type?: string): ThreeMfModelBuilder;
|
|
7868
7941
|
/**
|
|
7869
|
-
*
|
|
7870
|
-
* @param material
|
|
7871
|
-
* @returns
|
|
7942
|
+
* Adds a base materials group to the model resources.
|
|
7943
|
+
* @param material The base materials resource, or a builder that produces one.
|
|
7944
|
+
* @returns This builder, to allow chaining.
|
|
7872
7945
|
*/
|
|
7873
7946
|
withMaterial(material: I3mfBaseMaterials | ThreeMfMaterialBuilder): ThreeMfModelBuilder;
|
|
7874
7947
|
/**
|
|
7875
|
-
*
|
|
7876
|
-
* @param object
|
|
7877
|
-
* @returns
|
|
7948
|
+
* Adds a mesh object to the model resources.
|
|
7949
|
+
* @param object The object resource, or a builder that produces one.
|
|
7950
|
+
* @returns This builder, to allow chaining.
|
|
7878
7951
|
*/
|
|
7879
7952
|
withMesh(object: I3mfObject | ThreeMfMeshBuilder): ThreeMfModelBuilder;
|
|
7880
7953
|
/**
|
|
7881
|
-
*
|
|
7882
|
-
* @param components
|
|
7883
|
-
* @returns
|
|
7954
|
+
* Adds a components object to the model resources.
|
|
7955
|
+
* @param components The object resource, or a builder that produces one.
|
|
7956
|
+
* @returns This builder, to allow chaining.
|
|
7884
7957
|
*/
|
|
7885
7958
|
withComponents(components: I3mfObject | ThreeMfComponentsBuilder): ThreeMfModelBuilder;
|
|
7886
7959
|
/**
|
|
7887
|
-
*
|
|
7888
|
-
* @param objectid
|
|
7889
|
-
* @param transform
|
|
7890
|
-
* @param partnumber
|
|
7891
|
-
* @returns
|
|
7960
|
+
* Adds a build item, which places an object resource in the build plate.
|
|
7961
|
+
* @param objectid The resource id of the object to place.
|
|
7962
|
+
* @param transform The optional transform applied to the object.
|
|
7963
|
+
* @param partnumber The optional part number identifying the produced part.
|
|
7964
|
+
* @returns This builder, to allow chaining.
|
|
7892
7965
|
*/
|
|
7893
7966
|
withBuild(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string): ThreeMfModelBuilder;
|
|
7894
7967
|
/**
|
|
7895
|
-
*
|
|
7896
|
-
* @param unit
|
|
7897
|
-
* @returns
|
|
7968
|
+
* Sets the unit in which the model coordinates are expressed.
|
|
7969
|
+
* @param unit The 3MF unit (micron, millimeter, centimeter, inch, foot or meter).
|
|
7970
|
+
* @returns This builder, to allow chaining.
|
|
7898
7971
|
*/
|
|
7899
7972
|
withUnit(unit: ST_Unit): ThreeMfModelBuilder;
|
|
7900
7973
|
/**
|
|
7901
|
-
*
|
|
7902
|
-
* @returns
|
|
7974
|
+
* Discards the current model and starts building a new one.
|
|
7975
|
+
* @returns This builder, to allow chaining.
|
|
7903
7976
|
*/
|
|
7904
7977
|
reset(): ThreeMfModelBuilder;
|
|
7905
7978
|
/**
|
|
7906
|
-
*
|
|
7907
|
-
* @returns
|
|
7979
|
+
* Validates and returns the model that has been built.
|
|
7980
|
+
* @returns The built 3MF model.
|
|
7981
|
+
* @throws When the model has no object resource or no build item.
|
|
7908
7982
|
*/
|
|
7909
7983
|
build(): ThreeMfModel;
|
|
7910
7984
|
}
|
|
7911
7985
|
/**
|
|
7912
|
-
*
|
|
7986
|
+
* Fluent builder for a 3MF document, the OPC package that wraps the model.
|
|
7987
|
+
* It gathers the content types, the relationships and the model part.
|
|
7913
7988
|
*/
|
|
7914
7989
|
export class ThreeMfDocumentBuilder {
|
|
7915
7990
|
private _cts?;
|
|
7916
7991
|
private _rs?;
|
|
7917
7992
|
private _m?;
|
|
7918
7993
|
/**
|
|
7919
|
-
*
|
|
7920
|
-
* @param type
|
|
7921
|
-
* @returns
|
|
7994
|
+
* Declares an OPC content type. Duplicate declarations are ignored.
|
|
7995
|
+
* @param type The extension to content type mapping to declare.
|
|
7996
|
+
* @returns This builder, to allow chaining.
|
|
7922
7997
|
*/
|
|
7923
7998
|
withContentType(type: I3mfContentType): ThreeMfDocumentBuilder;
|
|
7924
7999
|
/**
|
|
7925
|
-
*
|
|
7926
|
-
*
|
|
7927
|
-
* @
|
|
8000
|
+
* Adds an OPC relationship and ensures the relationships content type is declared.
|
|
8001
|
+
* Relationships with an already registered id are ignored.
|
|
8002
|
+
* @param rel The relationship to add.
|
|
8003
|
+
* @returns This builder, to allow chaining.
|
|
7928
8004
|
*/
|
|
7929
8005
|
withRelationship(rel: I3mfRelationship): ThreeMfDocumentBuilder;
|
|
7930
8006
|
/**
|
|
7931
|
-
*
|
|
7932
|
-
* @param m
|
|
7933
|
-
* @returns
|
|
8007
|
+
* Sets the model part of the document and ensures the model content type is declared.
|
|
8008
|
+
* @param m The model resource, or a builder that produces one.
|
|
8009
|
+
* @returns This builder, to allow chaining.
|
|
7934
8010
|
*/
|
|
7935
8011
|
withModel(m: I3mfModel | ThreeMfModelBuilder): ThreeMfDocumentBuilder;
|
|
8012
|
+
/**
|
|
8013
|
+
* Validates and returns the document that has been built.
|
|
8014
|
+
* A default relationship pointing at the model part is generated when none was provided.
|
|
8015
|
+
* @returns The built 3MF document.
|
|
8016
|
+
* @throws When no model has been set.
|
|
8017
|
+
*/
|
|
7936
8018
|
build(): I3mfDocument;
|
|
7937
8019
|
}
|
|
7938
8020
|
|