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
|
@@ -3506,228 +3506,269 @@ declare namespace BABYLON {
|
|
|
3506
3506
|
}
|
|
3507
3507
|
|
|
3508
3508
|
|
|
3509
|
+
/**
|
|
3510
|
+
* Handler invoked for every vertex generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
3511
|
+
*/
|
|
3509
3512
|
export type VertexHandler = (vertex: I3mfVertex) => I3mfVertex;
|
|
3513
|
+
/**
|
|
3514
|
+
* Handler invoked for every triangle generated by a {@link ThreeMfMeshBuilder}, allowing it to be transformed before export.
|
|
3515
|
+
*/
|
|
3510
3516
|
export type TriangleHandler = (triangle: I3mfTriangle) => I3mfTriangle;
|
|
3511
|
-
/**
|
|
3517
|
+
/**
|
|
3518
|
+
* Fluent builder for a 3MF object resource.
|
|
3519
|
+
* An object is the base resource of a 3MF model and is either a mesh or a set of components.
|
|
3520
|
+
*/
|
|
3512
3521
|
export class ThreeMfObjectBuilder {
|
|
3513
3522
|
/**
|
|
3514
|
-
*
|
|
3523
|
+
* The 3MF object resource currently being built.
|
|
3515
3524
|
*/
|
|
3516
3525
|
protected _object: ThreeMfObject;
|
|
3517
3526
|
/**
|
|
3518
|
-
*
|
|
3519
|
-
* @param id
|
|
3520
|
-
* @param type
|
|
3527
|
+
* Creates a new object builder.
|
|
3528
|
+
* @param id The unique resource id of the object within the model.
|
|
3529
|
+
* @param type The 3MF object type (model, support, solidsupport, surface or other).
|
|
3521
3530
|
*/
|
|
3522
3531
|
constructor(id: ST_ResourceID, type: ST_ObjectType);
|
|
3523
3532
|
/**
|
|
3524
|
-
*
|
|
3525
|
-
* @param name
|
|
3526
|
-
* @returns
|
|
3533
|
+
* Sets the human readable name of the object.
|
|
3534
|
+
* @param name The name to assign to the object.
|
|
3535
|
+
* @returns This builder, to allow chaining.
|
|
3527
3536
|
*/
|
|
3528
3537
|
withName(name: string): ThreeMfObjectBuilder;
|
|
3529
3538
|
/**
|
|
3530
|
-
*
|
|
3531
|
-
* @param thumbnail
|
|
3532
|
-
* @returns
|
|
3539
|
+
* Sets the thumbnail of the object.
|
|
3540
|
+
* @param thumbnail The package relative path of the thumbnail part.
|
|
3541
|
+
* @returns This builder, to allow chaining.
|
|
3533
3542
|
*/
|
|
3534
3543
|
withThumbnail(thumbnail: string): ThreeMfObjectBuilder;
|
|
3535
3544
|
/**
|
|
3536
|
-
*
|
|
3537
|
-
* @param id
|
|
3538
|
-
* @param index
|
|
3539
|
-
* @returns
|
|
3545
|
+
* Assigns the property resource used by the object.
|
|
3546
|
+
* @param id The resource id of the property group (for example a base materials group).
|
|
3547
|
+
* @param index The zero based index of the property within the group. Defaults to 0.
|
|
3548
|
+
* @returns This builder, to allow chaining.
|
|
3540
3549
|
*/
|
|
3541
3550
|
withProperty(id: ST_ResourceIndex, index?: number): ThreeMfObjectBuilder;
|
|
3542
3551
|
/**
|
|
3543
|
-
*
|
|
3544
|
-
* @returns
|
|
3552
|
+
* Returns the object that has been built.
|
|
3553
|
+
* @returns The built 3MF object resource.
|
|
3545
3554
|
*/
|
|
3546
3555
|
build(): I3mfObject;
|
|
3547
3556
|
/**
|
|
3548
|
-
*
|
|
3549
|
-
* @param id
|
|
3550
|
-
* @param type
|
|
3557
|
+
* Discards the current object and starts building a new one.
|
|
3558
|
+
* @param id The unique resource id of the new object.
|
|
3559
|
+
* @param type The 3MF object type of the new object.
|
|
3551
3560
|
*/
|
|
3552
3561
|
reset(id: ST_ResourceID, type: ST_ObjectType): void;
|
|
3553
3562
|
}
|
|
3554
3563
|
/**
|
|
3555
|
-
*
|
|
3564
|
+
* Fluent builder for a 3MF object made of components.
|
|
3565
|
+
* A components object references other objects instead of defining its own geometry.
|
|
3556
3566
|
*/
|
|
3557
3567
|
export class ThreeMfComponentsBuilder extends ThreeMfObjectBuilder {
|
|
3558
3568
|
/**
|
|
3559
|
-
*
|
|
3560
|
-
* @param id
|
|
3561
|
-
* @param type
|
|
3569
|
+
* Creates a new components object builder.
|
|
3570
|
+
* @param id The unique resource id of the object within the model.
|
|
3571
|
+
* @param type The 3MF object type. Defaults to `ST_ObjectType.model`.
|
|
3562
3572
|
*/
|
|
3563
3573
|
constructor(id: ST_ResourceID, type?: ST_ObjectType);
|
|
3564
3574
|
/**
|
|
3565
|
-
*
|
|
3566
|
-
* @param id
|
|
3567
|
-
* @param t
|
|
3568
|
-
* @returns
|
|
3575
|
+
* Adds a component referencing another object resource.
|
|
3576
|
+
* @param id The resource id of the referenced object.
|
|
3577
|
+
* @param t The optional transform applied to the referenced object.
|
|
3578
|
+
* @returns This builder, to allow chaining.
|
|
3569
3579
|
*/
|
|
3570
3580
|
withComponent(id: ST_ResourceID, t?: Matrix3d): ThreeMfComponentsBuilder;
|
|
3571
3581
|
}
|
|
3572
3582
|
/**
|
|
3573
|
-
*
|
|
3583
|
+
* Fluent builder for a 3MF object holding a mesh.
|
|
3584
|
+
* Vertices and triangles are generated from Babylon vertex data and can be post processed through handlers.
|
|
3574
3585
|
*/
|
|
3575
3586
|
export class ThreeMfMeshBuilder extends ThreeMfObjectBuilder {
|
|
3576
3587
|
/**
|
|
3577
|
-
*
|
|
3588
|
+
* Optional handler invoked for every vertex before it is added to the mesh.
|
|
3578
3589
|
*/
|
|
3579
3590
|
_vh?: VertexHandler;
|
|
3580
3591
|
/**
|
|
3581
|
-
*
|
|
3592
|
+
* Optional handler invoked for every triangle before it is added to the mesh.
|
|
3582
3593
|
*/
|
|
3583
3594
|
_th?: TriangleHandler;
|
|
3584
3595
|
/**
|
|
3585
|
-
*
|
|
3586
|
-
* @param id
|
|
3596
|
+
* Creates a new mesh object builder.
|
|
3597
|
+
* @param id The unique resource id of the object within the model.
|
|
3587
3598
|
*/
|
|
3588
3599
|
constructor(id: ST_ResourceID);
|
|
3589
3600
|
/**
|
|
3590
|
-
*
|
|
3591
|
-
* @param vertex
|
|
3592
|
-
* @param triangle
|
|
3593
|
-
* @returns
|
|
3601
|
+
* Registers the handlers used to post process the generated geometry.
|
|
3602
|
+
* @param vertex The handler invoked for every generated vertex.
|
|
3603
|
+
* @param triangle The optional handler invoked for every generated triangle.
|
|
3604
|
+
* @returns This builder, to allow chaining.
|
|
3594
3605
|
*/
|
|
3595
3606
|
withPostProcessHandlers(vertex: VertexHandler, triangle?: TriangleHandler): ThreeMfMeshBuilder;
|
|
3596
3607
|
/**
|
|
3597
|
-
*
|
|
3598
|
-
* @param data
|
|
3599
|
-
* @returns
|
|
3608
|
+
* Builds the mesh content of the object from the provided vertex data.
|
|
3609
|
+
* @param data The positions and indices used to generate the mesh.
|
|
3610
|
+
* @returns This builder, to allow chaining.
|
|
3600
3611
|
*/
|
|
3601
3612
|
withData(data: I3mfVertexData): ThreeMfMeshBuilder;
|
|
3602
3613
|
/**
|
|
3603
|
-
*
|
|
3604
|
-
* @param id
|
|
3605
|
-
* @param i
|
|
3606
|
-
* @returns
|
|
3614
|
+
* Assigns the material used by the mesh.
|
|
3615
|
+
* @param id The resource id of the base materials group.
|
|
3616
|
+
* @param i The zero based index of the material within the group.
|
|
3617
|
+
* @returns This builder, to allow chaining.
|
|
3607
3618
|
*/
|
|
3608
3619
|
withMaterial(id: ST_ResourceID, i: number): ThreeMfMeshBuilder;
|
|
3609
3620
|
/**
|
|
3610
|
-
*
|
|
3611
|
-
* @param data
|
|
3612
|
-
* @returns
|
|
3621
|
+
* Converts vertex data into a 3MF mesh.
|
|
3622
|
+
* @param data The positions and indices used to generate the mesh.
|
|
3623
|
+
* @returns The generated 3MF mesh.
|
|
3613
3624
|
*/
|
|
3614
3625
|
private _buildMesh;
|
|
3626
|
+
/**
|
|
3627
|
+
* Converts a flat position array into a 3MF vertex list, applying the vertex handler when one is registered.
|
|
3628
|
+
* @param p The flat array of x, y and z positions.
|
|
3629
|
+
* @returns The generated 3MF vertex list.
|
|
3630
|
+
*/
|
|
3615
3631
|
private _buildVertices;
|
|
3632
|
+
/**
|
|
3633
|
+
* Converts a flat index array into a 3MF triangle list, applying the triangle handler when one is registered.
|
|
3634
|
+
* @param indice The flat array of vertex indices, three per triangle.
|
|
3635
|
+
* @returns The generated 3MF triangle list.
|
|
3636
|
+
*/
|
|
3616
3637
|
private _buildTriangle;
|
|
3617
3638
|
}
|
|
3618
3639
|
/**
|
|
3619
|
-
*
|
|
3640
|
+
* Fluent builder for a 3MF base materials resource.
|
|
3641
|
+
* Colors are stored as sRGB hexadecimal strings as required by the 3MF specification.
|
|
3620
3642
|
*/
|
|
3621
3643
|
export class ThreeMfMaterialBuilder {
|
|
3622
3644
|
private _m;
|
|
3645
|
+
/**
|
|
3646
|
+
* Creates a new base materials builder.
|
|
3647
|
+
* @param id The unique resource id of the base materials group within the model.
|
|
3648
|
+
*/
|
|
3623
3649
|
constructor(id: ST_ResourceID);
|
|
3624
3650
|
/**
|
|
3625
|
-
*
|
|
3626
|
-
* @param name
|
|
3627
|
-
* @param color
|
|
3628
|
-
* @returns
|
|
3651
|
+
* Adds a named color to the group, or updates it when the name already exists.
|
|
3652
|
+
* @param name The name of the material. The lookup is case insensitive.
|
|
3653
|
+
* @param color The linear RGBA color, converted to an sRGB hexadecimal string.
|
|
3654
|
+
* @returns This builder, to allow chaining.
|
|
3629
3655
|
*/
|
|
3630
3656
|
withColor(name: string, color: I3mfRGBAColor): ThreeMfMaterialBuilder;
|
|
3631
3657
|
/**
|
|
3632
|
-
*
|
|
3633
|
-
* @returns
|
|
3658
|
+
* Returns the base materials group that has been built.
|
|
3659
|
+
* @returns The built base materials resource.
|
|
3634
3660
|
*/
|
|
3635
3661
|
build(): I3mfBaseMaterials;
|
|
3662
|
+
/**
|
|
3663
|
+
* Converts a linear color into the sRGB hexadecimal string used by 3MF.
|
|
3664
|
+
* @param c The linear color to convert. The alpha channel is optional.
|
|
3665
|
+
* @returns The color as `#RRGGBB`, or `#RRGGBBAA` when an alpha channel is provided.
|
|
3666
|
+
*/
|
|
3636
3667
|
private _rgbaToHex;
|
|
3637
3668
|
}
|
|
3638
3669
|
/**
|
|
3639
|
-
*
|
|
3670
|
+
* Fluent builder for a 3MF model, the root part of a 3MF document.
|
|
3671
|
+
* It aggregates the resources (materials, meshes and components) and the build items that reference them.
|
|
3640
3672
|
*/
|
|
3641
3673
|
export class ThreeMfModelBuilder {
|
|
3642
3674
|
/**
|
|
3643
|
-
*
|
|
3675
|
+
* The lower cased set of the metadata names defined by the 3MF specification.
|
|
3644
3676
|
*/
|
|
3645
3677
|
static KnownMetaSet: Set<string>;
|
|
3646
3678
|
/**
|
|
3647
|
-
*
|
|
3679
|
+
* The 3MF model currently being built.
|
|
3648
3680
|
*/
|
|
3649
3681
|
_model: ThreeMfModel;
|
|
3650
3682
|
/**
|
|
3651
|
-
*
|
|
3683
|
+
* The object resources added to the model, indexed by resource id.
|
|
3652
3684
|
*/
|
|
3653
3685
|
_objects: Map<string, I3mfObject>;
|
|
3654
3686
|
/**
|
|
3655
|
-
*
|
|
3656
|
-
* @param name
|
|
3657
|
-
* @param value
|
|
3658
|
-
* @param preserve
|
|
3659
|
-
* @param type
|
|
3660
|
-
* @returns
|
|
3687
|
+
* Adds a metadata entry to the model.
|
|
3688
|
+
* @param name The metadata name. Names outside of the 3MF specification must be namespace qualified.
|
|
3689
|
+
* @param value The metadata value.
|
|
3690
|
+
* @param preserve Whether consumers must preserve this entry when editing the document.
|
|
3691
|
+
* @param type The XML schema type of the value. Defaults to `xs:string`.
|
|
3692
|
+
* @returns This builder, to allow chaining.
|
|
3661
3693
|
*/
|
|
3662
3694
|
withMetaData(name: string, value: string, preserve?: boolean, type?: string): ThreeMfModelBuilder;
|
|
3663
3695
|
/**
|
|
3664
|
-
*
|
|
3665
|
-
* @param material
|
|
3666
|
-
* @returns
|
|
3696
|
+
* Adds a base materials group to the model resources.
|
|
3697
|
+
* @param material The base materials resource, or a builder that produces one.
|
|
3698
|
+
* @returns This builder, to allow chaining.
|
|
3667
3699
|
*/
|
|
3668
3700
|
withMaterial(material: I3mfBaseMaterials | ThreeMfMaterialBuilder): ThreeMfModelBuilder;
|
|
3669
3701
|
/**
|
|
3670
|
-
*
|
|
3671
|
-
* @param object
|
|
3672
|
-
* @returns
|
|
3702
|
+
* Adds a mesh object to the model resources.
|
|
3703
|
+
* @param object The object resource, or a builder that produces one.
|
|
3704
|
+
* @returns This builder, to allow chaining.
|
|
3673
3705
|
*/
|
|
3674
3706
|
withMesh(object: I3mfObject | ThreeMfMeshBuilder): ThreeMfModelBuilder;
|
|
3675
3707
|
/**
|
|
3676
|
-
*
|
|
3677
|
-
* @param components
|
|
3678
|
-
* @returns
|
|
3708
|
+
* Adds a components object to the model resources.
|
|
3709
|
+
* @param components The object resource, or a builder that produces one.
|
|
3710
|
+
* @returns This builder, to allow chaining.
|
|
3679
3711
|
*/
|
|
3680
3712
|
withComponents(components: I3mfObject | ThreeMfComponentsBuilder): ThreeMfModelBuilder;
|
|
3681
3713
|
/**
|
|
3682
|
-
*
|
|
3683
|
-
* @param objectid
|
|
3684
|
-
* @param transform
|
|
3685
|
-
* @param partnumber
|
|
3686
|
-
* @returns
|
|
3714
|
+
* Adds a build item, which places an object resource in the build plate.
|
|
3715
|
+
* @param objectid The resource id of the object to place.
|
|
3716
|
+
* @param transform The optional transform applied to the object.
|
|
3717
|
+
* @param partnumber The optional part number identifying the produced part.
|
|
3718
|
+
* @returns This builder, to allow chaining.
|
|
3687
3719
|
*/
|
|
3688
3720
|
withBuild(objectid: ST_ResourceID, transform?: Matrix3d, partnumber?: string): ThreeMfModelBuilder;
|
|
3689
3721
|
/**
|
|
3690
|
-
*
|
|
3691
|
-
* @param unit
|
|
3692
|
-
* @returns
|
|
3722
|
+
* Sets the unit in which the model coordinates are expressed.
|
|
3723
|
+
* @param unit The 3MF unit (micron, millimeter, centimeter, inch, foot or meter).
|
|
3724
|
+
* @returns This builder, to allow chaining.
|
|
3693
3725
|
*/
|
|
3694
3726
|
withUnit(unit: ST_Unit): ThreeMfModelBuilder;
|
|
3695
3727
|
/**
|
|
3696
|
-
*
|
|
3697
|
-
* @returns
|
|
3728
|
+
* Discards the current model and starts building a new one.
|
|
3729
|
+
* @returns This builder, to allow chaining.
|
|
3698
3730
|
*/
|
|
3699
3731
|
reset(): ThreeMfModelBuilder;
|
|
3700
3732
|
/**
|
|
3701
|
-
*
|
|
3702
|
-
* @returns
|
|
3733
|
+
* Validates and returns the model that has been built.
|
|
3734
|
+
* @returns The built 3MF model.
|
|
3735
|
+
* @throws When the model has no object resource or no build item.
|
|
3703
3736
|
*/
|
|
3704
3737
|
build(): ThreeMfModel;
|
|
3705
3738
|
}
|
|
3706
3739
|
/**
|
|
3707
|
-
*
|
|
3740
|
+
* Fluent builder for a 3MF document, the OPC package that wraps the model.
|
|
3741
|
+
* It gathers the content types, the relationships and the model part.
|
|
3708
3742
|
*/
|
|
3709
3743
|
export class ThreeMfDocumentBuilder {
|
|
3710
3744
|
private _cts?;
|
|
3711
3745
|
private _rs?;
|
|
3712
3746
|
private _m?;
|
|
3713
3747
|
/**
|
|
3714
|
-
*
|
|
3715
|
-
* @param type
|
|
3716
|
-
* @returns
|
|
3748
|
+
* Declares an OPC content type. Duplicate declarations are ignored.
|
|
3749
|
+
* @param type The extension to content type mapping to declare.
|
|
3750
|
+
* @returns This builder, to allow chaining.
|
|
3717
3751
|
*/
|
|
3718
3752
|
withContentType(type: I3mfContentType): ThreeMfDocumentBuilder;
|
|
3719
3753
|
/**
|
|
3720
|
-
*
|
|
3721
|
-
*
|
|
3722
|
-
* @
|
|
3754
|
+
* Adds an OPC relationship and ensures the relationships content type is declared.
|
|
3755
|
+
* Relationships with an already registered id are ignored.
|
|
3756
|
+
* @param rel The relationship to add.
|
|
3757
|
+
* @returns This builder, to allow chaining.
|
|
3723
3758
|
*/
|
|
3724
3759
|
withRelationship(rel: I3mfRelationship): ThreeMfDocumentBuilder;
|
|
3725
3760
|
/**
|
|
3726
|
-
*
|
|
3727
|
-
* @param m
|
|
3728
|
-
* @returns
|
|
3761
|
+
* Sets the model part of the document and ensures the model content type is declared.
|
|
3762
|
+
* @param m The model resource, or a builder that produces one.
|
|
3763
|
+
* @returns This builder, to allow chaining.
|
|
3729
3764
|
*/
|
|
3730
3765
|
withModel(m: I3mfModel | ThreeMfModelBuilder): ThreeMfDocumentBuilder;
|
|
3766
|
+
/**
|
|
3767
|
+
* Validates and returns the document that has been built.
|
|
3768
|
+
* A default relationship pointing at the model part is generated when none was provided.
|
|
3769
|
+
* @returns The built 3MF document.
|
|
3770
|
+
* @throws When no model has been set.
|
|
3771
|
+
*/
|
|
3731
3772
|
build(): I3mfDocument;
|
|
3732
3773
|
}
|
|
3733
3774
|
|