Skip to content

Commit d4fab7c

Browse files
committed
fix: correct mesher bugs
1 parent 34f6d2c commit d4fab7c

File tree

4 files changed

+16
-27
lines changed

4 files changed

+16
-27
lines changed

packages/front/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@thatopen/components-front",
33
"description": "Collection of frontend tools to author BIM apps.",
4-
"version": "3.1.3",
4+
"version": "3.1.4",
55
"author": "That Open Company",
66
"contributors": [
77
"Antonio Gonzalez Viegas (https://github.com/agviegas)",

packages/front/src/fragments/Hoverer/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,6 @@ export class Hoverer extends OBC.Component implements OBC.Disposable {
180180
const meshes = [...data.values()].flat();
181181
for (const mesh of meshes) {
182182
mesh.material = this.material;
183-
mesh.position.set(0, 0, 0);
184-
mesh.rotation.set(0, 0, 0);
185-
mesh.scale.set(1, 1, 1);
186-
mesh.applyMatrix4(model.object.matrixWorld);
187183
this._meshes.add(mesh);
188184
}
189185
}

packages/front/src/fragments/Mesher/index.ts

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ export class Mesher extends OBC.Component implements OBC.Disposable {
2323
* @param modelIdMap - A map of model IDs to an array of local IDs, specifying which items to retrieve meshes for.
2424
* @param _config - Optional configuration object.
2525
* @param _config.material - Optional material to apply to the meshes. If not provided, the default material is used.
26-
* @param _config.coordinate - Whether to apply coordinate system transformation. Defaults to `true`.
2726
* @param _config.applyTransformation - Whether to bring the mesh to its original position or leave it at 0,0,0. Defaults to `true`.
2827
* @returns A map of model IDs to a map of local IDs to an array of THREE.Mesh objects.
2928
*/
@@ -35,13 +34,15 @@ export class Mesher extends OBC.Component implements OBC.Disposable {
3534
applyTransformation?: boolean;
3635
},
3736
) {
38-
const { material, coordinate, applyTransformation } = {
39-
coordinate: true,
37+
// Get options
38+
const { material, applyTransformation } = {
4039
applyTransformation: true,
4140
..._config,
4241
};
42+
4343
const fragments = this.components.get(OBC.FragmentsManager);
4444
const result: OBC.ModelIdDataMap<THREE.Mesh[]> = new FRAGS.DataMap();
45+
4546
for (const [modelId, localIds] of Object.entries(modelIdMap)) {
4647
const model = fragments.list.get(modelId);
4748
if (!model) continue;
@@ -55,11 +56,10 @@ export class Mesher extends OBC.Component implements OBC.Disposable {
5556
let itemGeometries = modelGeometries.get(localId);
5657
if (itemGeometries && itemGeometries.length > 0) {
5758
const meshes: THREE.Mesh[] = [];
58-
for (const [_, { geometry }] of itemGeometries.entries()) {
59-
const mesh = await this.createMesh(model, geometry, {
59+
for (const [_, { geometry, transform }] of itemGeometries.entries()) {
60+
const mesh = await this.createMesh(model, geometry, transform, {
6061
material,
6162
applyTransformation,
62-
coordinate,
6363
});
6464
meshes.push(mesh);
6565
}
@@ -75,12 +75,11 @@ export class Mesher extends OBC.Component implements OBC.Disposable {
7575
for (const data of meshData) {
7676
const geometryData = this.createGeometry(data);
7777
if (!geometryData) continue;
78-
const { geometry } = geometryData;
78+
const { geometry, transform } = geometryData;
7979
itemGeometries.push(geometryData);
80-
const mesh = await this.createMesh(model, geometry, {
80+
const mesh = await this.createMesh(model, geometry, transform, {
8181
material,
8282
applyTransformation,
83-
coordinate,
8483
});
8584
itemMeshes.push(mesh);
8685
}
@@ -146,31 +145,29 @@ export class Mesher extends OBC.Component implements OBC.Disposable {
146145
new THREE.BufferAttribute(normals, 3, true),
147146
);
148147
geometry.setIndex(new THREE.BufferAttribute(indices, 1));
149-
geometry.applyMatrix4(transform);
148+
// geometry.applyMatrix4(transform);
150149
return { geometry, transform };
151150
}
152151

153152
private async createMesh(
154153
model: FRAGS.FragmentsModel,
155154
geometry: THREE.BufferGeometry,
155+
transform: THREE.Matrix4,
156156
_config?: {
157157
material?: THREE.Material;
158158
applyTransformation?: boolean;
159-
coordinate?: boolean;
160159
},
161160
) {
162-
const { material, applyTransformation, coordinate } = {
161+
const { material, applyTransformation } = {
163162
applyTransformation: true,
164-
coordinate: true,
165163
..._config,
166164
};
167-
const fragments = this.components.get(OBC.FragmentsManager);
168165
const mesh = new THREE.Mesh(geometry, material);
166+
mesh.applyMatrix4(transform);
169167
mesh.applyMatrix4(model.object.matrixWorld);
170-
if (!applyTransformation) mesh.position.set(0, 0, 0);
171-
if (coordinate && fragments.baseCoordinationModel !== model.modelId) {
172-
const matrix = await model.getCoordinationMatrix();
173-
fragments.applyBaseCoordinateSystem(mesh, matrix);
168+
if (!applyTransformation) {
169+
mesh.position.set(0, 0, 0);
170+
mesh.rotation.set(0, 0, 0);
174171
}
175172
return mesh;
176173
}

packages/front/src/fragments/Outliner/index.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -220,10 +220,6 @@ export class Outliner extends OBC.Component implements OBC.Disposable {
220220
for (const [_, data] of meshes.entries()) {
221221
const meshes = [...data.values()].flat();
222222
for (const mesh of meshes) {
223-
mesh.position.set(0, 0, 0);
224-
mesh.rotation.set(0, 0, 0);
225-
mesh.scale.set(1, 1, 1);
226-
mesh.applyMatrix4(model.object.matrixWorld);
227223
this._meshes.push(mesh);
228224
outlinePass.scene.add(mesh);
229225
}

0 commit comments

Comments
 (0)