@@ -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 }
0 commit comments