breaking change: Change "type" to be a keyword, import() "type:" parameter to "format:" (#4517)
This commit is contained in:
File diff suppressed because one or more lines are too long
@ -78138,10 +78138,10 @@
|
||||
"description": "Autodesk Filmbox (FBX) format",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
"format"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"fbx"
|
||||
@ -78153,10 +78153,10 @@
|
||||
"description": "Binary glTF 2.0. We refer to this as glTF since that is how our customers refer to it, but this can also import binary glTF (glb).",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
"format"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"gltf"
|
||||
@ -78168,11 +78168,11 @@
|
||||
"description": "Wavefront OBJ format.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"format",
|
||||
"units"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"obj"
|
||||
@ -78201,11 +78201,11 @@
|
||||
"description": "The PLY Polygon File Format.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"format",
|
||||
"units"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"ply"
|
||||
@ -78234,10 +78234,10 @@
|
||||
"description": "SolidWorks part (SLDPRT) format.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
"format"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"sldprt"
|
||||
@ -78249,10 +78249,10 @@
|
||||
"description": "ISO 10303-21 (STEP) format.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
"format"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"step"
|
||||
@ -78264,11 +78264,11 @@
|
||||
"description": "ST**ereo**L**ithography format.",
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type",
|
||||
"format",
|
||||
"units"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"format": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"stl"
|
||||
@ -78506,7 +78506,7 @@
|
||||
"deprecated": false,
|
||||
"examples": [
|
||||
"model = import(\"tests/inputs/cube.obj\")",
|
||||
"model = import(\"tests/inputs/cube.obj\", { type: \"obj\", units: \"m\" })",
|
||||
"model = import(\"tests/inputs/cube.obj\", { format: \"obj\", units: \"m\" })",
|
||||
"model = import(\"tests/inputs/cube.gltf\")",
|
||||
"model = import(\"tests/inputs/cube.sldprt\")",
|
||||
"model = import(\"tests/inputs/cube.step\")",
|
||||
|
@ -24,7 +24,7 @@ Autodesk Filmbox (FBX) format
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `fbx`| | No |
|
||||
| `format` |enum: `fbx`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -40,7 +40,7 @@ Binary glTF 2.0. We refer to this as glTF since that is how our customers refer
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `gltf`| | No |
|
||||
| `format` |enum: `gltf`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -56,7 +56,7 @@ Wavefront OBJ format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `obj`| | No |
|
||||
| `format` |enum: `obj`| | No |
|
||||
| `coords` |[`System`](/docs/kcl/types/System)| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `units` |[`UnitLength`](/docs/kcl/types/UnitLength)| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||
|
||||
@ -74,7 +74,7 @@ The PLY Polygon File Format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `ply`| | No |
|
||||
| `format` |enum: `ply`| | No |
|
||||
| `coords` |[`System`](/docs/kcl/types/System)| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `units` |[`UnitLength`](/docs/kcl/types/UnitLength)| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||
|
||||
@ -92,7 +92,7 @@ SolidWorks part (SLDPRT) format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `sldprt`| | No |
|
||||
| `format` |enum: `sldprt`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -108,7 +108,7 @@ ISO 10303-21 (STEP) format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `step`| | No |
|
||||
| `format` |enum: `step`| | No |
|
||||
|
||||
|
||||
----
|
||||
@ -124,7 +124,7 @@ ST**ereo**L**ithography format.
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `stl`| | No |
|
||||
| `format` |enum: `stl`| | No |
|
||||
| `coords` |[`System`](/docs/kcl/types/System)| Co-ordinate system of input data. Defaults to the [KittyCAD co-ordinate system. | No |
|
||||
| `units` |[`UnitLength`](/docs/kcl/types/UnitLength)| The units of the input data. This is very important for correct scaling and when calculating physics properties like mass, etc. Defaults to millimeters. | No |
|
||||
|
||||
|
@ -692,7 +692,7 @@ macro_rules! let_field_of {
|
||||
impl<'a> FromKclValue<'a> for crate::std::import::ImportFormat {
|
||||
fn from_kcl_val(arg: &'a KclValue) -> Option<Self> {
|
||||
let obj = arg.as_object()?;
|
||||
let_field_of!(obj, typ "type");
|
||||
let_field_of!(obj, typ "format");
|
||||
match typ {
|
||||
"fbx" => Some(Self::Fbx {}),
|
||||
"gltf" => Some(Self::Gltf {}),
|
||||
|
@ -42,7 +42,7 @@ const ZOO_COORD_SYSTEM: System = System {
|
||||
/// Import format specifier
|
||||
#[derive(serde :: Serialize, serde :: Deserialize, PartialEq, Debug, Clone, schemars :: JsonSchema)]
|
||||
#[cfg_attr(feature = "tabled", derive(tabled::Tabled))]
|
||||
#[serde(tag = "type")]
|
||||
#[serde(tag = "format")]
|
||||
pub enum ImportFormat {
|
||||
/// Autodesk Filmbox (FBX) format
|
||||
#[serde(rename = "fbx")]
|
||||
@ -152,7 +152,7 @@ pub async fn import(exec_state: &mut ExecState, args: Args) -> Result<KclValue,
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
/// const model = import("tests/inputs/cube.obj", {type: "obj", units: "m"})
|
||||
/// const model = import("tests/inputs/cube.obj", {format: "obj", units: "m"})
|
||||
/// ```
|
||||
///
|
||||
/// ```no_run
|
||||
|
@ -42,6 +42,7 @@ lazy_static! {
|
||||
set.insert("const", TokenType::Keyword);
|
||||
// "import" is special because of import().
|
||||
set.insert("export", TokenType::Keyword);
|
||||
set.insert("type", TokenType::Keyword);
|
||||
set.insert("interface", TokenType::Keyword);
|
||||
set.insert("new", TokenType::Keyword);
|
||||
set.insert("self", TokenType::Keyword);
|
||||
|
@ -1685,7 +1685,7 @@ things = "things"
|
||||
let some_program_string = r#"b = {
|
||||
end: 141,
|
||||
start: 125,
|
||||
type: "NonCodeNode",
|
||||
type_: "NonCodeNode",
|
||||
value: "
|
||||
// a comment
|
||||
"
|
||||
|
@ -526,7 +526,7 @@ async fn kcl_test_import_obj_with_mtl() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_import_obj_with_mtl_units() {
|
||||
let code = r#"model = import("tests/executor/inputs/cube.obj", {type: "obj", units: "m"})"#;
|
||||
let code = r#"model = import("tests/executor/inputs/cube.obj", {format: "obj", units: "m"})"#;
|
||||
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await.unwrap();
|
||||
assert_out("import_obj_with_mtl_units", &result);
|
||||
@ -574,13 +574,13 @@ async fn kcl_test_import_glb_no_assign() {
|
||||
|
||||
#[tokio::test(flavor = "multi_thread")]
|
||||
async fn kcl_test_import_ext_doesnt_match() {
|
||||
let code = r#"model = import("tests/executor/inputs/cube.gltf", {type: "obj", units: "m"})"#;
|
||||
let code = r#"model = import("tests/executor/inputs/cube.gltf", {format: "obj", units: "m"})"#;
|
||||
|
||||
let result = execute_and_snapshot(code, UnitLength::Mm).await;
|
||||
assert!(result.is_err());
|
||||
assert_eq!(
|
||||
result.err().unwrap().to_string(),
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([8, 76, 0])], message: "The given format does not match the file extension. Expected: `gltf`, Given: `obj`" }"#
|
||||
r#"semantic: KclErrorDetails { source_ranges: [SourceRange([8, 78, 0])], message: "The given format does not match the file extension. Expected: `gltf`, Given: `obj`" }"#
|
||||
);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user