@@ -235,8 +235,29 @@ export class FragmentsManager extends Component implements Disposable {
235235 model . rotation . set ( 0 , 0 , 0 ) ;
236236 model . scale . set ( 1 , 1 , 1 ) ;
237237 model . updateMatrix ( ) ;
238- model . applyMatrix4 ( model . coordinationMatrix . clone ( ) . invert ( ) ) ;
239- model . applyMatrix4 ( this . baseCoordinationMatrix ) ;
238+ this . applyBaseCoordinateSystem ( model , model . coordinationMatrix ) ;
240239 }
241240 }
241+
242+ /**
243+ * Applies the base coordinate system to the provided object.
244+ *
245+ * This function takes an object and its original coordinate system as input.
246+ * It then inverts the original coordinate system and applies the base coordinate system
247+ * to the object. This ensures that the object's position, rotation, and scale are
248+ * transformed to match the base coordinate system (which is taken from the first model loaded).
249+ *
250+ * @param object - The object to which the base coordinate system will be applied.
251+ * This should be an instance of THREE.Object3D.
252+ *
253+ * @param originalCoordinateSystem - The original coordinate system of the object.
254+ * This should be a THREE.Matrix4 representing the object's transformation matrix.
255+ */
256+ applyBaseCoordinateSystem (
257+ object : THREE . Object3D ,
258+ originalCoordinateSystem : THREE . Matrix4 ,
259+ ) {
260+ object . applyMatrix4 ( originalCoordinateSystem . clone ( ) . invert ( ) ) ;
261+ object . applyMatrix4 ( this . baseCoordinationMatrix ) ;
262+ }
242263}
0 commit comments