@bldrs-ai/conway 0.23.977 → 1.322.1027
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/README.md +77 -40
- package/compiled/Dist/ConwayGeomWasm.d.ts +2 -0
- package/compiled/Dist/ConwayGeomWasmNode.d.ts +2 -0
- package/compiled/Dist/ConwayGeomWasmNodeMT.d.ts +2 -0
- package/compiled/Dist/ConwayGeomWasmWeb.d.ts +2 -0
- package/compiled/Dist/ConwayGeomWasmWebMT.d.ts +2 -0
- package/compiled/examples/browser-bundled.cjs +1 -1
- package/compiled/examples/cli-bundled.cjs +1 -1
- package/compiled/examples/validator-bundled.cjs +1 -1
- package/compiled/src/AP214E3_2010/ap214_geometry_extraction.d.ts +33 -3
- package/compiled/src/AP214E3_2010/ap214_geometry_extraction.d.ts.map +1 -1
- package/compiled/src/AP214E3_2010/ap214_geometry_extraction.js +156 -111
- package/compiled/src/AP214E3_2010/ap214_geometry_extraction.test.js +79 -0
- package/compiled/src/AP214E3_2010/ap214_scene_builder.d.ts +10 -5
- package/compiled/src/AP214E3_2010/ap214_scene_builder.d.ts.map +1 -1
- package/compiled/src/AP214E3_2010/ap214_scene_builder.js +10 -5
- package/compiled/src/AP214E3_2010/ap214_transform_helpers.test.d.ts +2 -0
- package/compiled/src/AP214E3_2010/ap214_transform_helpers.test.d.ts.map +1 -0
- package/compiled/src/AP214E3_2010/ap214_transform_helpers.test.js +112 -0
- package/compiled/src/format_detection/model_format_detector.d.ts +2 -1
- package/compiled/src/format_detection/model_format_detector.d.ts.map +1 -1
- package/compiled/src/format_detection/model_format_detector.js +12 -11
- package/compiled/src/format_detection/model_format_detector.test.js +11 -0
- package/compiled/src/loaders/conway_model_loader.d.ts.map +1 -1
- package/compiled/src/loaders/conway_model_loader.js +8 -1
- package/compiled/src/version/version.d.ts.map +1 -1
- package/compiled/src/version/version.js +1 -1
- package/compiled/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
|
@@ -112,6 +112,85 @@ describe("AP214 Geometry Extraction", () => {
|
|
|
112
112
|
const testParameter = 48108;
|
|
113
113
|
expect(getGearMeshSize()).toBe(testParameter);
|
|
114
114
|
});
|
|
115
|
+
test("uniformScaleAffine scales basis AND translation, preserves bottom row", () => {
|
|
116
|
+
// Direct unit test for the affine scale helper used by the unit-conversion
|
|
117
|
+
// path in doTransforms (see https://github.com/bldrs-ai/conway/issues/308).
|
|
118
|
+
// Models a placement in mm with a 1000 mm x-translation, 50 mm
|
|
119
|
+
// y-translation, converted to metres (factor = 1/MM_PER_M).
|
|
120
|
+
const MM_PER_M = 1000;
|
|
121
|
+
const TX_MM = 1000;
|
|
122
|
+
const TY_MM = 50;
|
|
123
|
+
const factor = 1 / MM_PER_M;
|
|
124
|
+
const model = conwayTubeModel;
|
|
125
|
+
const input = new model.wasmModule.Glmdmat4();
|
|
126
|
+
// Column-major: cols 0..2 = basis (identity), col 3 = translation
|
|
127
|
+
input.setValues([
|
|
128
|
+
1,
|
|
129
|
+
0,
|
|
130
|
+
0,
|
|
131
|
+
0,
|
|
132
|
+
0,
|
|
133
|
+
1,
|
|
134
|
+
0,
|
|
135
|
+
0,
|
|
136
|
+
0,
|
|
137
|
+
0,
|
|
138
|
+
1,
|
|
139
|
+
0,
|
|
140
|
+
TX_MM,
|
|
141
|
+
TY_MM,
|
|
142
|
+
0,
|
|
143
|
+
1,
|
|
144
|
+
]);
|
|
145
|
+
const v = model.uniformScaleAffine(input, factor).getValues();
|
|
146
|
+
// Basis diagonal scaled by factor.
|
|
147
|
+
expect(v[0]).toBeCloseTo(factor);
|
|
148
|
+
expect(v[5]).toBeCloseTo(factor);
|
|
149
|
+
expect(v[10]).toBeCloseTo(factor);
|
|
150
|
+
// Translation scaled by factor (mm -> m). This is the bug the C++
|
|
151
|
+
// `uniformScale` left in source units before; the helper fixes it.
|
|
152
|
+
expect(v[12]).toBeCloseTo(TX_MM * factor);
|
|
153
|
+
expect(v[13]).toBeCloseTo(TY_MM * factor);
|
|
154
|
+
expect(v[14]).toBeCloseTo(0);
|
|
155
|
+
// Bottom row left at [0, 0, 0, 1].
|
|
156
|
+
expect(v[3]).toBe(0);
|
|
157
|
+
expect(v[7]).toBe(0);
|
|
158
|
+
expect(v[11]).toBe(0);
|
|
159
|
+
expect(v[15]).toBe(1);
|
|
160
|
+
});
|
|
161
|
+
test("uniformScaleAffine with factor=1 returns the original matrix entries", () => {
|
|
162
|
+
const model = conwayTubeModel;
|
|
163
|
+
// A column-major rotation+translation matrix with non-trivial entries
|
|
164
|
+
// (60-degree z-rotation, arbitrary translation).
|
|
165
|
+
const COS60 = Math.cos(Math.PI / 3);
|
|
166
|
+
const SIN60 = Math.sin(Math.PI / 3);
|
|
167
|
+
const TY = 20;
|
|
168
|
+
const TZ = 30;
|
|
169
|
+
const original = [
|
|
170
|
+
COS60,
|
|
171
|
+
SIN60,
|
|
172
|
+
0,
|
|
173
|
+
0,
|
|
174
|
+
-SIN60,
|
|
175
|
+
COS60,
|
|
176
|
+
0,
|
|
177
|
+
0,
|
|
178
|
+
0,
|
|
179
|
+
0,
|
|
180
|
+
1,
|
|
181
|
+
0,
|
|
182
|
+
10,
|
|
183
|
+
TY,
|
|
184
|
+
TZ,
|
|
185
|
+
1,
|
|
186
|
+
];
|
|
187
|
+
const input = new model.wasmModule.Glmdmat4();
|
|
188
|
+
input.setValues(original);
|
|
189
|
+
const v = model.uniformScaleAffine(input, 1).getValues();
|
|
190
|
+
for (let i = 0; i < original.length; ++i) {
|
|
191
|
+
expect(v[i]).toBeCloseTo(original[i]);
|
|
192
|
+
}
|
|
193
|
+
});
|
|
115
194
|
test("destroy()", () => {
|
|
116
195
|
expect(destroy()).toBe(false);
|
|
117
196
|
});
|
|
@@ -180,12 +180,17 @@ export declare class AP214SceneBuilder implements WalkableScene<StepEntityBase<E
|
|
|
180
180
|
*/
|
|
181
181
|
addGeometry(localID: number, owningElementLocalID?: number, materialOverridLocalID?: number): AP214SceneGeometry;
|
|
182
182
|
/**
|
|
183
|
+
* Add a transform node and make the current transform stack parent its parent.
|
|
183
184
|
*
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
*
|
|
187
|
-
*
|
|
188
|
-
* @
|
|
185
|
+
* Items added will be made the top of the transform stack.
|
|
186
|
+
*
|
|
187
|
+
* To prevent a node being used as a parent, pop it subsequently.
|
|
188
|
+
*
|
|
189
|
+
* @param localID The local ID of the transform.
|
|
190
|
+
* @param transform The transform matrix.
|
|
191
|
+
* @param nativeTransform The native transform matrix.
|
|
192
|
+
* @param mappedItem Whether the transform is a mapped item.
|
|
193
|
+
* @return The added transform node.
|
|
189
194
|
*/
|
|
190
195
|
addTransform(localID: number, transform: ReadonlyArray<number>, nativeTransform: NativeTransform4x4, mappedItem?: boolean): AP214SceneTransform;
|
|
191
196
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ap214_scene_builder.d.ts","sourceRoot":"","sources":["../../../src/AP214E3_2010/ap214_scene_builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAkB,kBAAkB,EAAwB,MACjF,gCAAgC,CAAA;AAClC,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAA;AAC9D,OAAO,EAAE,aAAa,EAAqB,MAAM,wBAAwB,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA;AAClF,OAAO,EACL,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EACnB,MACM,oBAAoB,CAAA;AAE3B,OAAO,cAAc,MAAM,0BAA0B,CAAA;AACrD,OAAO,gBAAgB,MAAM,2CAA2C,CAAA;AACxE,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,cAAc,MAAM,oBAAoB,CAAA;AAG/C;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AAO,EAAE,MAAM,GAAG,OAAO;IAK5C;;;;;;OAMG;IACI,WAAW,CACd,OAAO,EAAE,MAAM,EACf,oBAAoB,CAAC,EAAE,MAAM,EAC7B,sBAAsB,CAAC,EAAE,MAAM,GAAI,kBAAkB;IA8DzD;;;;;;;;;;;;OAYG;IACI,YAAY,CACf,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,aAAa,CAAC,MAAM,CAAC,EAChC,eAAe,EAAE,kBAAkB,EACnC,UAAU,GAAE,OAAe,GAAI,mBAAmB;CAsEvD"}
|
|
@@ -372,12 +372,17 @@ export class AP214SceneBuilder {
|
|
|
372
372
|
return result;
|
|
373
373
|
}
|
|
374
374
|
/**
|
|
375
|
+
* Add a transform node and make the current transform stack parent its parent.
|
|
375
376
|
*
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
*
|
|
379
|
-
*
|
|
380
|
-
* @
|
|
377
|
+
* Items added will be made the top of the transform stack.
|
|
378
|
+
*
|
|
379
|
+
* To prevent a node being used as a parent, pop it subsequently.
|
|
380
|
+
*
|
|
381
|
+
* @param localID The local ID of the transform.
|
|
382
|
+
* @param transform The transform matrix.
|
|
383
|
+
* @param nativeTransform The native transform matrix.
|
|
384
|
+
* @param mappedItem Whether the transform is a mapped item.
|
|
385
|
+
* @return The added transform node.
|
|
381
386
|
*/
|
|
382
387
|
addTransform(localID, transform, nativeTransform, mappedItem = false) {
|
|
383
388
|
if (!mappedItem && this.sceneLocalIdMap_.has(localID)) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ap214_transform_helpers.test.d.ts","sourceRoot":"","sources":["../../../src/AP214E3_2010/ap214_transform_helpers.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import fs from "fs";
|
|
2
|
+
import { describe, expect, test, beforeAll, afterAll } from "@jest/globals";
|
|
3
|
+
import { AP214GeometryExtraction } from "./ap214_geometry_extraction.js";
|
|
4
|
+
import { AP214SceneTransform } from "./ap214_scene_builder.js";
|
|
5
|
+
import { ParseResult } from "../step/parsing/step_parser.js";
|
|
6
|
+
import IfcStepParser from "./ap214_step_parser.js";
|
|
7
|
+
import ParsingBuffer from "../parsing/parsing_buffer.js";
|
|
8
|
+
import { ConwayGeometry } from "../../dependencies/conway-geom/index.js";
|
|
9
|
+
import { cartesian_transformation_operator_3d, mapped_item, } from "./AP214E3_2010_gen/index.js";
|
|
10
|
+
let extraction;
|
|
11
|
+
let conwayGeometry;
|
|
12
|
+
/**
|
|
13
|
+
* Parse data/ap214-mapped-item-test.step and create an AP214GeometryExtraction
|
|
14
|
+
* for testing transform helpers (extractMappedItem origin-inversion semantics
|
|
15
|
+
* from PR #309 and extractCartesianTransformOperator3D parameter packaging).
|
|
16
|
+
*
|
|
17
|
+
* @return {Promise<boolean>} True iff parse + WASM init succeeded.
|
|
18
|
+
*/
|
|
19
|
+
async function initialize() {
|
|
20
|
+
const parser = IfcStepParser.Instance;
|
|
21
|
+
const buffer = fs.readFileSync("data/ap214-mapped-item-test.step");
|
|
22
|
+
const input = new ParsingBuffer(buffer);
|
|
23
|
+
if (parser.parseHeader(input)[1] !== ParseResult.COMPLETE) {
|
|
24
|
+
return false;
|
|
25
|
+
}
|
|
26
|
+
conwayGeometry = new ConwayGeometry();
|
|
27
|
+
if (!(await conwayGeometry.initialize())) {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
const [, model] = parser.parseDataToModel(input);
|
|
31
|
+
if (model === void 0) {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
extraction = new AP214GeometryExtraction(conwayGeometry, model);
|
|
35
|
+
return extraction.isInitialized();
|
|
36
|
+
}
|
|
37
|
+
describe("AP214 transform helpers", () => {
|
|
38
|
+
beforeAll(async () => {
|
|
39
|
+
await initialize();
|
|
40
|
+
});
|
|
41
|
+
afterAll(() => {
|
|
42
|
+
extraction?.destroy();
|
|
43
|
+
});
|
|
44
|
+
test("parses fixture and finds the mapped_item + CTO3D entities", () => {
|
|
45
|
+
const mappedItems = Array.from(extraction.model.types(mapped_item));
|
|
46
|
+
const ctos = Array.from(extraction.model.types(cartesian_transformation_operator_3d));
|
|
47
|
+
expect(mappedItems.length).toBe(1);
|
|
48
|
+
expect(ctos.length).toBe(1);
|
|
49
|
+
});
|
|
50
|
+
test("extractCartesianTransformOperator3D produces a non-trivial matrix with the entity origin", () => {
|
|
51
|
+
// Fixture has CARTESIAN_TRANSFORMATION_OPERATOR_3D('',$,$,#13,2.,$)
|
|
52
|
+
// with #13 = CARTESIAN_POINT('',(50.,0.,0.)). Verifies the helper
|
|
53
|
+
// packages local_origin into the returned matrix's translation
|
|
54
|
+
// column (column-major v[12..14]).
|
|
55
|
+
const CTO_ORIGIN_X = 50;
|
|
56
|
+
const MAT_4X4_ENTRIES = 16;
|
|
57
|
+
const ctos = Array.from(extraction.model.types(cartesian_transformation_operator_3d));
|
|
58
|
+
const cto = ctos[0];
|
|
59
|
+
const result = extraction.extractCartesianTransformOperator3D(cto);
|
|
60
|
+
const v = result.getValues();
|
|
61
|
+
expect(v.length).toBe(MAT_4X4_ENTRIES);
|
|
62
|
+
// Translation reflects the entity's local_origin.
|
|
63
|
+
expect(v[12]).toBeCloseTo(CTO_ORIGIN_X);
|
|
64
|
+
expect(v[13]).toBeCloseTo(0);
|
|
65
|
+
expect(v[14]).toBeCloseTo(0);
|
|
66
|
+
// Bottom row sane for an affine 4x4.
|
|
67
|
+
expect(v[3]).toBeCloseTo(0);
|
|
68
|
+
expect(v[7]).toBeCloseTo(0);
|
|
69
|
+
expect(v[11]).toBeCloseTo(0);
|
|
70
|
+
});
|
|
71
|
+
test("extractMappedItem composes target * origin^-1 for a placement target", () => {
|
|
72
|
+
// Fixture has:
|
|
73
|
+
// origin placement #30 at (10, 0, 0)
|
|
74
|
+
// target placement #31 at (100, 0, 0)
|
|
75
|
+
// mapped_item #60 mapping #30 -> #31
|
|
76
|
+
//
|
|
77
|
+
// Per PR #309 (line 2298-2308 of ap214_geometry_extraction.ts): the
|
|
78
|
+
// pushed transform is `target * origin^-1`. With identity rotations
|
|
79
|
+
// and translations as above, the result's translation column should
|
|
80
|
+
// be (100 - 10, 0, 0) = (90, 0, 0).
|
|
81
|
+
//
|
|
82
|
+
// Regression guard: if origin^-1 were dropped, the result would be
|
|
83
|
+
// the bare target translation (100, 0, 0).
|
|
84
|
+
const EXPECTED_TX = 90;
|
|
85
|
+
const TARGET_ONLY_TX = 100;
|
|
86
|
+
const mappedItems = Array.from(extraction.model.types(mapped_item));
|
|
87
|
+
const mi = mappedItems[0];
|
|
88
|
+
const sceneInternal = extraction.scene;
|
|
89
|
+
const indexBefore = sceneInternal.scene_.length;
|
|
90
|
+
extraction.extractMappedItem(mi);
|
|
91
|
+
// The first scene node added by extractMappedItem is the combined
|
|
92
|
+
// transform itself (pushed with mapped_item's localID); subsequent
|
|
93
|
+
// nodes come from the recursive extraction of mapped_representation.
|
|
94
|
+
let pushed;
|
|
95
|
+
for (let i = indexBefore; i < sceneInternal.scene_.length; ++i) {
|
|
96
|
+
const node = sceneInternal.scene_[i];
|
|
97
|
+
if (node instanceof AP214SceneTransform && node.localID === mi.localID) {
|
|
98
|
+
pushed = node;
|
|
99
|
+
break;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
expect(pushed).toBeDefined();
|
|
103
|
+
const v = pushed.transform;
|
|
104
|
+
// Combined translation = target - origin = 100 - 10 = 90 along X.
|
|
105
|
+
expect(v[12]).toBeCloseTo(EXPECTED_TX);
|
|
106
|
+
expect(v[13]).toBeCloseTo(0);
|
|
107
|
+
expect(v[14]).toBeCloseTo(0);
|
|
108
|
+
// If the origin inversion were ever removed, v[12] would land at
|
|
109
|
+
// TARGET_ONLY_TX. Spell that out so a regressed value reads clearly.
|
|
110
|
+
expect(v[12]).not.toBeCloseTo(TARGET_ONLY_TX);
|
|
111
|
+
});
|
|
112
|
+
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model_format_detector.d.ts","sourceRoot":"","sources":["../../../src/format_detection/model_format_detector.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,aAAa,MAAM,2BAA2B,CAAA;AAIrD,oBAAY,eAAe;IAEzB,GAAG,IAAI;IAEP,KAAK,IAAI;CACV;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAEtC;;;;;;OAMG;WACW,MAAM,CAAE,KAAK,EAAE,aAAa,GAAI,eAAe,GAAG,SAAS;
|
|
1
|
+
{"version":3,"file":"model_format_detector.d.ts","sourceRoot":"","sources":["../../../src/format_detection/model_format_detector.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH,OAAO,aAAa,MAAM,2BAA2B,CAAA;AAIrD,oBAAY,eAAe;IAEzB,GAAG,IAAI;IAEP,KAAK,IAAI;IAET,KAAK,IAAI;CACV;AAED;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAmB;IAEtC;;;;;;OAMG;WACW,MAAM,CAAE,KAAK,EAAE,aAAa,GAAI,eAAe,GAAG,SAAS;CAiC1E"}
|
|
@@ -6,6 +6,7 @@ export var ModelFormatType;
|
|
|
6
6
|
(function (ModelFormatType) {
|
|
7
7
|
ModelFormatType[ModelFormatType["IFC"] = 0] = "IFC";
|
|
8
8
|
ModelFormatType[ModelFormatType["AP214"] = 1] = "AP214";
|
|
9
|
+
ModelFormatType[ModelFormatType["AP203"] = 2] = "AP203";
|
|
9
10
|
})(ModelFormatType || (ModelFormatType = {}));
|
|
10
11
|
/**
|
|
11
12
|
* Format detector for finding the format of a model from a buffer in conway.
|
|
@@ -20,22 +21,22 @@ export default class ModelFormatDetector {
|
|
|
20
21
|
*/
|
|
21
22
|
static detect(input) {
|
|
22
23
|
const [stepHeader, errorCode] = StepHeaderParser.instance.parseHeader(input);
|
|
23
|
-
console.log(ParseResult[errorCode]);
|
|
24
24
|
if (errorCode === ParseResult.COMPLETE || errorCode === ParseResult.INCOMPLETE) {
|
|
25
25
|
const schema = stepHeader.headers.get("FILE_SCHEMA")?.toLocaleUpperCase();
|
|
26
26
|
if (schema !== void 0) {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
const afterBrace = schema.substring(schema.indexOf("{") + 1).trimStart();
|
|
36
|
-
if (afterBrace.startsWith("1 0 10303 214")) {
|
|
27
|
+
const quotedEntries = Array.from(schema.matchAll(/'([^']+)'/g)).map((match) => match[1]);
|
|
28
|
+
const schemaEntries = quotedEntries.length > 0 ? quotedEntries : [schema];
|
|
29
|
+
for (const rawEntry of schemaEntries) {
|
|
30
|
+
const entryNoSpaces = rawEntry.replaceAll(" ", "");
|
|
31
|
+
if (entryNoSpaces.startsWith("IFC")) {
|
|
32
|
+
return ModelFormatType.IFC;
|
|
33
|
+
}
|
|
34
|
+
if (entryNoSpaces.startsWith("AUTOMOTIVE_DESIGN")) {
|
|
37
35
|
return ModelFormatType.AP214;
|
|
38
36
|
}
|
|
37
|
+
if (entryNoSpaces.startsWith("CONFIG_CONTROL_DESIGN")) {
|
|
38
|
+
return ModelFormatType.AP203;
|
|
39
|
+
}
|
|
39
40
|
}
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -5,11 +5,13 @@ import ModelFormatDetector, { ModelFormatType } from "./model_format_detector.js
|
|
|
5
5
|
const indexIfcBuffer = fs.readFileSync("data/index.ifc");
|
|
6
6
|
const tubeBuffer = fs.readFileSync("data/create-a-tube.step");
|
|
7
7
|
const gearBuffer = fs.readFileSync("data/a-gear-with-3-inch-diameter-and-20-curved-teeth.step");
|
|
8
|
+
const configControlDesignBuffer = fs.readFileSync("data/config-control-design-min.step");
|
|
8
9
|
const nativeHDBuffer = fs.readFileSync("data/native_hd.m3u8");
|
|
9
10
|
const emptyBuffer = new Uint8Array(0);
|
|
10
11
|
const indexIfcBufferInput = new ParsingBuffer(indexIfcBuffer);
|
|
11
12
|
const tubeBufferInput = new ParsingBuffer(tubeBuffer);
|
|
12
13
|
const gearBufferInput = new ParsingBuffer(gearBuffer);
|
|
14
|
+
const configControlDesignBufferInput = new ParsingBuffer(configControlDesignBuffer);
|
|
13
15
|
const nativeHDBufferInput = new ParsingBuffer(nativeHDBuffer);
|
|
14
16
|
const emptyBufferInput = new ParsingBuffer(emptyBuffer);
|
|
15
17
|
/**
|
|
@@ -30,6 +32,12 @@ function testTubeStep() {
|
|
|
30
32
|
function testGearStep() {
|
|
31
33
|
return ModelFormatDetector.detect(gearBufferInput);
|
|
32
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* @return {ModelFormatType} The type for model formats, should be AP203.
|
|
37
|
+
*/
|
|
38
|
+
function testConfigControlDesignStep() {
|
|
39
|
+
return ModelFormatDetector.detect(configControlDesignBufferInput);
|
|
40
|
+
}
|
|
33
41
|
/**
|
|
34
42
|
* @return {ModelFormatType} The type for model formats, should be AP214.
|
|
35
43
|
*/
|
|
@@ -52,6 +60,9 @@ describe("Model Format Detector", () => {
|
|
|
52
60
|
test("testGearStep()", () => {
|
|
53
61
|
expect(testGearStep()).toBe(ModelFormatType.AP214);
|
|
54
62
|
});
|
|
63
|
+
test("testConfigControlDesignStep()", () => {
|
|
64
|
+
expect(testConfigControlDesignStep()).toBe(ModelFormatType.AP203);
|
|
65
|
+
});
|
|
55
66
|
test("testNotAModel()", () => {
|
|
56
67
|
expect(testNotAModel()).toBe(void 0);
|
|
57
68
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conway_model_loader.d.ts","sourceRoot":"","sources":["../../../src/loaders/conway_model_loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAcrC;;;;GAIG;AACH,qBAAa,iBAAiB;IAE5B;;;;;;;;OAQG;WACiB,kBAAkB,CAClC,IAAI,EAAE,UAAU,EAChB,aAAa,GAAE,OAAc,EAC7B,eAAe,GAAE,MAAW,EAC5B,OAAO,GAAE,MAAU,GAAI,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"conway_model_loader.d.ts","sourceRoot":"","sources":["../../../src/loaders/conway_model_loader.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AACrC,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAcrC;;;;GAIG;AACH,qBAAa,iBAAiB;IAE5B;;;;;;;;OAQG;WACiB,kBAAkB,CAClC,IAAI,EAAE,UAAU,EAChB,aAAa,GAAE,OAAc,EAC7B,eAAe,GAAE,MAAW,EAC5B,OAAO,GAAE,MAAU,GAAI,OAAO,CAAC,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;CA8XnD"}
|
|
@@ -30,10 +30,17 @@ export class ConwayModelLoader {
|
|
|
30
30
|
static async loadModelWithScene(data, limitCSGDepth = true, maximumCSGDepth = 20, modelID = 0) {
|
|
31
31
|
const allTimeStart = Date.now();
|
|
32
32
|
const modelFormat = ModelFormatDetector.detect(new ParsingBuffer(data));
|
|
33
|
+
let is203 = false;
|
|
33
34
|
switch (modelFormat) {
|
|
35
|
+
case ModelFormatType.AP203:
|
|
36
|
+
console.log("AP203 Step Detected, using AP214 loader");
|
|
37
|
+
is203 = true;
|
|
38
|
+
// falls through
|
|
34
39
|
case ModelFormatType.AP214:
|
|
35
|
-
|
|
40
|
+
if (!is203) {
|
|
36
41
|
console.log("AP214 Step Detected");
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
37
44
|
const conwayWasm = new ConwayGeometry();
|
|
38
45
|
if (!await conwayWasm.initialize()) {
|
|
39
46
|
throw Error("Couldn't initialise conway-geom");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version/version.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,EAAE,
|
|
1
|
+
{"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/version/version.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,aAAa,EAAE,MAA0C,CAAA;AAG/D,OAAO,EAAC,aAAa,EAAC,CAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const versionString = 'Conway Web-Ifc Shim
|
|
1
|
+
const versionString = 'Conway Web-Ifc Shim v1.322.1027';
|
|
2
2
|
export { versionString };
|