Method, device and product for rendering bim model and positioning component based on three.js
By merging components of the BIM model and using an octree and the Raycaster class from Three.js for click detection, the issues of smoothness and interactivity in large-scale BIM model rendering were resolved, achieving efficient component positioning and information retrieval, and improving the user experience.
Patent Information
- Application Number
- CN202411711393.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-26
- Publication Date
- 2025-11-25
- Estimated Expiration
- 2044-11-26
AI Technical Summary
In the web-based rendering of BIM models in the steel industry, existing optimization methods are insufficient to meet the requirements for smoothness and interactivity of large-scale BIM models. In particular, merged components cannot be accessed by clicking on individual components, which affects the user experience.
By merging multiple independent components that meet predetermined conditions into a single model, and using an octree to partition the space and store the component bounding box coordinates, and combining this with the Raycaster class in Three.js for click detection, precise positioning and information retrieval of components can be achieved.
It reduces rendering pressure, improves rendering performance and interactivity on the web, and can quickly respond to user clicks and queries, meeting the detailed interactive needs of large-scale BIM models.
Smart Images

Figure CN119690559B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of BIM model rendering, in particular to a method and device for BIM model rendering and component positioning based on Three.js, and a product. BACKGROUND
[0002] Unlike the general construction industry, in the steel industry, BIM models, i.e., building information models, usually contain a large number of complex components and parts, which can cause great pressure in the process of web-side three.js rendering, resulting in rendering frame drop or browser crash.
[0003] In the rendering of BIM models on the web side, in the face of large-scale BIM models, such as BIM models containing hundreds of thousands of component data, the current commonly used optimization methods include LOD, i.e., the detail level method, the model level loading method and the InstancedMesh optimization method. Among them:
[0004] LOD method: LOD dynamically loads different resolution model versions according to the camera distance, displays low resolution models at a distance, and displays high resolution at a close distance. The disadvantages of LOD include: in the BIM scene, the LOD still has a large rendering burden for the model observed at a close distance, especially when there are a large number of high-resolution components in the same view, resource consumption cannot be avoided; and LOD is complex to implement, requiring layer-by-layer storage and loading of model data, increasing the burden of storage and management;
[0005] Model level loading: loading model data in batches or dividing the model into regions, and loading the corresponding region model only in the visible range; the disadvantages of model level loading include: level loading will cause delay when initially loaded and frequently switched between regions, affecting user experience; for large-scale BIM data, each model loading and switching will still significantly stress the rendering resources;
[0006] InstancedMesh optimization: rendering the same geometry, such as repeated beams and columns, by instantiation; the disadvantages of InstancedMesh optimization include: although it reduces repeated rendering, it has no effect on a large number of unique components, and instantiation still requires additional data structures to support the selection and interaction of individual components.
[0007] As can be seen from the above, although the above methods optimize the rendering performance to some extent, they still cannot meet the requirements of smoothness and interactivity in the web-side rendering of large-scale BIM models. SUMMARY
[0008] Embodiments of the present application provide a method, device and product for BIM model rendering and component positioning based on Three.js, to maintain single component click query on the basis of merged models, thereby meeting the requirements of fluency and interactivity in web-side rendering of large-scale BIM models.
[0009] To achieve the above-mentioned purpose, in one aspect, a method for BIM model rendering and component positioning based on Three.js is provided, comprising:
[0010] Merging a plurality of independent components in an imported BIM model that meet predetermined merging conditions into a whole model, and saving the coordinates of the bounding box of each independent component in the plurality of independent components;
[0011] Dividing the space of the BIM model into a plurality of subspaces using an octree, and generating a plurality of nodes corresponding to the plurality of subspaces;
[0012] According to the coordinates of the bounding box of each independent component in the plurality of independent components and the subspaces corresponding to the octree nodes, each independent component in the plurality of independent components is assigned to the corresponding octree node;
[0013] After the BIM model is loaded into the front end display, in response to a click on the whole model, determining the screen coordinates of the click point corresponding to the click, and converting the screen coordinates into three-dimensional space coordinates of the click point in the BIM model;
[0014] According to the three-dimensional space coordinates of the click point in the BIM model, determining the minimum octree node in the octree node to which the click point belongs, which is the smallest subspace;
[0015] Determining the independent component in which the bounding box of at least one independent component contained in the minimum octree node contains the click point as the target component corresponding to the click.
[0016] Preferably, the method, wherein after determining the target component corresponding to the click, further comprising: returning the information of the target component to the front end.
[0017] Preferably, the method, wherein the step of merging the plurality of independent components into a whole model comprises:
[0018] Obtaining the world coordinates of each independent component in the plurality of independent components in the world coordinate system;
[0019] According to the world coordinates of each independent component in the world coordinate system, merging the plurality of independent components to generate a merged component corresponding to the whole model;
[0020] Generate a Mesh object corresponding to the overall model based on the merged components;
[0021] Add the Mesh object to the selected scene to replace the multiple individual components in the selected scene.
[0022] Preferably, the method further includes, after adding the Mesh object to the selected scene, removing the multiple independent components.
[0023] Preferably, in the method, the multiple independent components have a uniform material before being merged.
[0024] Preferably, the method, in which the step of dividing the space of the BIM model into multiple subspaces using an octree and generating multiple nodes corresponding to the multiple subspaces includes:
[0025] The global space of the BIM model is initialized as the root node of an octree;
[0026] Starting from the global space, the space is recursively divided into eight subspaces according to the center point, and eight child nodes are generated corresponding to the eight subspaces. The division of the subspace stops when the number of independent components contained in the subspace is less than or equal to a predetermined number. Each octree node records: the node's own boundary, the identifier of its own parent node, the identifier of its own child nodes, the depth of the current node, and the information of the components it contains. The information of the components includes: the component identifier and the coordinates of the component bounding box.
[0027] Preferably, the method, wherein the step of converting the screen coordinates into the three-dimensional spatial coordinates of the click point in the BIM model includes:
[0028] The screen coordinates are normalized to obtain normalized coordinates;
[0029] Using the Raycaster class in Three.js, the normalized coordinates are mapped onto the camera's view frustum to generate a ray that extends along the direction from the camera to the 3D space.
[0030] Using the intersectObject or intersectObjects method of Raycaster, the intersection point of the ray and the Mesh object is detected to obtain the position coordinates of the intersection point and the information of the object intersecting with the intersection point; wherein, the position coordinates of the intersection point are determined as the three-dimensional spatial coordinates of the click point.
[0031] In another aspect, an electronic device is provided, comprising a memory and a processor, the memory storing at least one program, the at least one program being executed by the processor to implement the method for rendering a Three.js-based BIM model and positioning a component according to any one of the above.
[0032] In yet another aspect, a computer-readable storage medium is provided, the storage medium storing at least one program, the at least one program being executed by a processor to implement the method for rendering a Three.js-based BIM model and positioning a component according to any one of the above.
[0033] In yet another aspect, a computer program product is provided, comprising a computer program, characterized by the computer program being executed by a processor to implement the steps of the method for rendering a Three.js-based BIM model and positioning a component according to any one of the above.
[0034] The above technical solutions have the following technical effects:
[0035] The technical solution of the embodiment of the present application realizes the combination of component model merging and interactive reservation, reduces the rendering pressure and reduces the rendering resource consumption through model merging, improves the rendering of the Web end, and enables the user to obtain the information of a single component through clicking even after merging, thereby meeting the fine interactive demand of the BIM model;
[0036] By applying the octree to the click detection of a large volume model, the coordinate positioning query is accelerated, the background query speed is significantly improved, the problem of being unable to accurately position after merging components is solved, the system response speed is improved, and the method is suitable for large-scale BIM models;
[0037] By rendering the overall model on the front end and performing coordinate query in the background, the rendering optimization and query efficiency are considered, and the method is suitable for the Web end application of large-scale BIM models. BRIEF DESCRIPTION OF DRAWINGS
[0038] Figure 1 FIG. 1 is a flowchart of a method for rendering a Three.js-based BIM model and positioning a component according to an embodiment of the present application;
[0039] Figure 2 FIG. 2 is a flowchart of component merging in the method for rendering a Three.js-based BIM model and positioning a component according to an embodiment of the present application;
[0040] Figure 3 FIG. 3 is a code example of implementing component merging in the method for rendering a Three.js-based BIM model and positioning a component according to an embodiment of the present application;
[0041] Figure 4 An exemplary flowchart of octree construction in the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application;
[0042] Figure 5 An exemplary JSON code of MongoDB document of an octree node in the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application;
[0043] Figure 6 An exemplary flowchart of converting screen coordinates into three-dimensional space coordinates of a click point in a BIM model in the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application;
[0044] Figure 7 An exemplary code of converting screen coordinates into three-dimensional space coordinates of a click point in a BIM model in the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application;
[0045] Figure 8 An exemplary flowchart of querying and positioning components through a background in the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application;
[0046] Figure 9 An exemplary flowchart of specific implementation of the Three.js-based BIM model rendering and component positioning method of an embodiment of the present application. DETAILED DESCRIPTION
[0047] To further illustrate the embodiments, the present application provides accompanying drawings. These drawings are part of the disclosure of the present application, and mainly serve to illustrate the embodiments, and can be used to explain the operating principles of the embodiments in conjunction with the relevant descriptions of the specification. Those of ordinary skill in the art should be able to understand other possible implementations and advantages of the present application in conjunction with these contents. The components in the drawings are not drawn to scale, and similar component symbols are generally used to represent similar components.
[0048] The present application will be further described in conjunction with the accompanying drawings and specific embodiments.
[0049] The inventors of the present application found that in the rendering method of a large-scale BIM model, the rendering pressure can be greatly reduced by merging components, but in the prior art, after the individual components are merged, the relevant attribute information of the individual components cannot usually be obtained by clicking the whole model after merging; and in the usual business requirements, the user often needs to click to locate a component to view its information or perform other operations, so these components are often not allowed to be merged. To solve this problem, the present application proposes a new rendering and component positioning method for a large-scale BIM model.
[0050] The BIM model rendering and component positioning method based on Three.js of the present application reduces the rendering pressure by merging independent components, and when the user wants to locate a specific independent component, the user only needs to select, such as click, the position of the independent component in the model after merging, and by locating the coordinates of the click point in the background, the specific independent component that the user wants to locate can be located, so that the rendering pressure of the large-scale BIM model is reduced, and the user's interactive experience is improved.
[0051] The implementation logic of the present application includes:
[0052] Model merging: all independent components in the BIM model that meet the predetermined merging conditions are merged to generate a whole model, reducing the rendering frequency of individual components, thereby reducing resource occupation and improving rendering efficiency;
[0053] Space partitioning of octree and background data storage: when the model is merged, the bounding box coordinates of each component are recorded and stored in a database or cache; the space of the model is partitioned using an octree to speed up subsequent queries;
[0054] Mouse click detection: when a mouse click is detected, Three.js obtains the three-dimensional space coordinates of the click point; and the coordinates are transmitted to the background for querying;
[0055] Background query and component positioning: after receiving the coordinates in the background, the octree is used to find the spatial region to which the point belongs, and the component list in the region is further matched, and finally the specific component in which the click point is located is determined through boundary detection.
[0056] Embodiment one:
[0057] Figure 1 The flowchart of the BIM model rendering and component positioning method based on Three.js of an embodiment of the present application. As Figure 1 , the BIM model rendering method based on Three.js of this embodiment includes:
[0058] 101, merge multiple independent components in the imported BIM model that meet the predetermined merging conditions into a whole model, and save the coordinates of the bounding box of each independent component; in one specific implementation, the bounding box is determined by the point (x min , y min , z min ) composed of the minimum coordinates of the x-axis direction, the minimum coordinates of the y-axis direction, and the minimum coordinates of the z-axis direction in the three-dimensional world coordinate system of each point contained in the independent component, and the point (x max , y max , z max ) composed of the maximum coordinates of the x-axis direction, the maximum coordinates of the y-axis direction, and the maximum coordinates of the z-axis direction; in one specific implementation, the bounding box is a cube determined by the above two points; the coordinates of the bounding box include the coordinates of the above two points. In one specific implementation, similar components that meet the predetermined similarity condition are merged into one whole.
[0059] In one specific implementation, the interfaces such as BufferGeometry and Mesh provided by Three.js are used to merge multiple components, i.e., component geometries, and create a more efficient rendering object. Figure 2 The flowchart for component merging.
[0060] As Figure 2 , component merging includes:
[0061] Extracting components, i.e., geometries, from the original component model;
[0062] Converting the geometries into coordinates in the world coordinate system;
[0063] Merging the geometries;
[0064] Generating the merged Mesh;
[0065] Replacing the original independent components with the merged Mesh.
[0066] The following describes each step in detail:
[0067] 1) Initialize the components, i.e., geometries, and materials:
[0068] Get all independent component models that need to be merged, and ensure that their materials are the same or can be unified, otherwise the materials need to be processed before merging;
[0069] Create a BufferGeometry object to store the merged geometry data; the above geometry data includes the point-line-face data corresponding to the component, such as vertex coordinates, face indices, etc.
[0070] Iterate through each component model:
[0071] applyMatrix4 method is performed on the BufferGeometry of each component to transform its local coordinates in the corresponding design software, such as bentley, to the world coordinate system; this step is used to ensure the position of the components for correct merging;
[0072] The geometry data of each component is merged into a large geometry using mergeBufferGeometries, i.e. the overall model of the merged components is obtained;
[0073] 2) Create a Mesh corresponding to the above-mentioned merged overall model:
[0074] A new Mesh object is created using the merged BufferGeometry and uniform material, and this merged Mesh contains the geometry data of all original independent components;
[0075] The Mesh is added to the scene, i.e. the selected three-dimensional scene, to replace all the previous independent components;
[0076] 3) Clean up the memory:
[0077] The original separate independent components are removed to release the memory and optimize the rendering performance.
[0078] Among them, the key interface of Three.js is described as follows:
[0079] BufferGeometry: the component in Three.js, i.e. the geometry data structure, supports efficient data storage and operation;
[0080] applyMatrix4: transform the vertex coordinates of the geometry to the world coordinate system for correct merging of the components, i.e. the geometry;
[0081] mergeBufferGeometries: merge multiple BufferGeometry into one overall geometry.
[0082] Figure 3 Code examples for implementing component merging.
[0083] 102, using octree to divide the space of BIM model into multiple subspaces and generating multiple nodes corresponding to the multiple subspaces;
[0084] In a specific implementation, the step 102 comprises: initializing a global space of the BIM model as a root node of an octree; starting from the global space, recursively splitting the space into eight sub-spaces according to a center point and generating eight sub-nodes corresponding to the eight sub-spaces, until the number of independent components contained in a sub-space is less than or equal to a predetermined number, and the splitting of the sub-space is stopped; wherein each octree node records: the boundary of the node itself, the identification of the parent node of the node itself, the identification of the child nodes of the node itself, the depth of the current node, and the information of the contained components, the information of the components including: the component identification and the coordinates of the component bounding box.
[0085] Figure 4 An exemplary flowchart of octree construction in an embodiment of the present application is shown in FIG. 1. Figure 4 The octree construction in an embodiment of the present application comprises:
[0086] Divide the global space into 8 regions;
[0087] Check the number of components in each region;
[0088] When the number of components in a region is less than or equal to a predetermined number threshold, it is determined that the region meets the condition for stopping the splitting, and the region is no longer split and is retained; otherwise, when the number of components in the region is greater than the predetermined number threshold, the region is further divided or split; the way of further dividing or splitting is: the region or space is further divided into 8 sub-regions or sub-spaces; repeat the above component number checking step, stop the splitting, and retain the region or continue the splitting; wherein the splitting can start from the center point of the region or space or from other points selected in advance. The recursive splitting is achieved through such division or splitting. Figure 3 Region 1 is retained, and regions 2 and 3 are further divided.
[0089] Exemplarily, the space division of the octree is implemented based on Three.js and comprises:
[0090] 1) Initialize the root node:
[0091] The root node of the octree represents the entire space range (e.g. the outer bounding box of the entire scene), each node contains a unique ID, boundary coordinates, depth information, and a list of child nodes.
[0092] 2) Recursively split the node:
[0093] Recursively split the space into eight sub-spaces according to a center point and generate eight child nodes;
[0094] Each node records its own boundary, and contains the ID of the parent node, the depth of the current node, and the preliminary information of the component; the preliminary information of the component includes the coordinates of the corresponding bounding box and the ID of the component;
[0095] The node nesting is stored in MongoDB, and the identification field, i.e., the _id field, is used to uniquely identify each node;
[0096] 3) Store the node and the child node:
[0097] a) Store each node as a MongoDB document; each document records the node boundary, the child node ID, the component data, the level of the current node, i.e., the depth, and the like; Figure 5 For each octree node, a json code example of the MongoDB document is shown.
[0098] b) In the component data, the ID, position, and boundary information of the component are stored to facilitate subsequent accurate positioning.
[0099] 103. According to the coordinates of the bounding box of each independent component in the plurality of independent components and the corresponding subspace of the octree node, each independent component in the plurality of independent components is assigned to the corresponding octree node;
[0100] This step realizes the assignment of the component to the octree node, specifically:
[0101] For each component, check whether its bounding box, i.e., the bounding box, is within the range of the current node;
[0102] If the range of the bounding box of the component is smaller than the range of the current node and within the range of the node, it is regarded as the component of the node and stored in the component list of the node, otherwise, it is recursively assigned to a smaller child node.
[0103] The embodiment of the application realizes the octree space partitioning and background data storage of the BIM model through steps 102 and 103. In a specific implementation, the background database selects a NoSQL database, i.e., MongoDB. The octree storage and space partitioning are realized in MongoDB, the nested structure of the document is used to recursively represent the octree node, and the spatial index is used to efficiently retrieve data.
[0104] 104. After the BIM model is loaded to the front end for display, in response to the clicking on the whole model, the screen coordinates of the clicking point corresponding to the clicking are determined, and the screen coordinates are converted into the three-dimensional space coordinates of the clicking point in the BIM model; in a specific implementation, in response to the selection or clicking of a single component in the whole model by the user, such as the clicking using a mouse;
[0105] Figure 6A flowchart for converting screen coordinates to three-dimensional space coordinates of a click point in a BIM model in a specific implementation. Figure 7 A code example for converting screen coordinates to three-dimensional space coordinates of a click point in a BIM model in a Three.js-based BIM model rendering and component positioning method according to an embodiment of the present application.
[0106] As Figure 6 The coordinate conversion process includes:
[0107] Normalizing the screen coordinates to obtain normalized coordinates;
[0108] Using the Raycaster class of Three.js to map the normalized coordinates to a ray in the camera frustum, the ray extending along the direction from the camera to the three-dimensional space;
[0109] Using the intersectObject or intersectObjects method of Raycaster to detect the intersection of the ray and the Mesh object;
[0110] Determining whether the intersection exists; if so, returning the position coordinates of the intersection point and the object information intersecting with the intersection point; otherwise, no intersection, no operation; wherein the position coordinates of the intersection point are determined as the three-dimensional space coordinates of the click point.
[0111] In this way, accurate conversion from screen coordinates to three-dimensional coordinates and click detection can be achieved, effectively identifying which component the user clicks on and obtaining its spatial coordinates.
[0112] 105. Determine the smallest octree node in the octree node to which the click point belongs according to the three-dimensional space coordinates of the click point in the BIM model;
[0113] 106. Determine the independent component contained in the smallest octree node as the target component corresponding to the click. Further, return the information such as attributes of the target component to the front end.
[0114] The above steps 105 and 106 achieve the query or retrieval of independent components in the BIM model space. Specifically:
[0115] When querying or retrieving, according to the point selected by the user on the screen, i.e. the click point, the coordinates of the point are obtained, and the smallest octree node containing the point is recursively queried from the root node; using the spatial index of MongoDB, the node in which the click point is located can be found quickly.
[0116] Figure 8A flowchart of a process of querying and positioning a component by a background in an embodiment of the present application. As shown in Figure 8 The querying and positioning of a component by a background comprises:
[0117] Octree positioning: after a user clicks to generate a click point coordinate, the coordinate is sent to the background, which starts from the root node in the octree to find and gradually position the sub-space region where the click point is located until the smallest sub-region containing the point is found; specifically, it is determined whether the click point is within the range of the current node; if so, it is further determined whether the current node has a child node; if the child node exists, the child node is recursively checked; if the child node does not exist, the smallest sub-region containing the click point is found, and the following boundary detection step is continued;
[0118] Boundary detection: the component list in the sub-region is obtained; the boundary box of the component is traversed, and for each component, it is determined whether the click point is within the boundary box of the component, i.e., whether the boundary box of the component contains the coordinate of the click point, to further narrow down the range of the searched component;
[0119] Final positioning of the component: if the click point is located in the boundary box of a certain component, the component is determined as the target clicked, i.e., the target component, and the component identification, i.e., the component ID, of the component is returned; otherwise, the next component is continuously checked.
[0120] Figure 9 A flowchart of a specific implementation of a BIM model rendering and component positioning method based on Three.js in an embodiment of the present application. As shown in Figure 9 The specific implementation comprises:
[0121] BIM model import;
[0122] Merging of component geometries, i.e., merging of a plurality of selected independent components;
[0123] Recording of the boundary boxes and corresponding coordinates of the independent components;
[0124] Construction of an octree storage space division information;
[0125] Loading of the BIM model after the components are merged to the front end for display;
[0126] Response to a user click event, i.e., an event of a user clicking the merged overall model in the BIM model;
[0127] Sending of the coordinate of the click point to the background, which uses octree query in the background;
[0128] Positioning of a component list containing the click point;
[0129] Traversal of the component boundary;
[0130] Determine the component ID corresponding to the specific clicked component in the overall model;
[0131] Query the attribute information of the component;
[0132] Return the attribute information of the component to the front end.
[0133] Embodiment two:
[0134] The application also provides an electronic device comprising a memory and a processor, wherein the memory stores at least one program, and the at least one program is executed by the processor to implement the method for rendering a Three.js-based BIM model and locating a component according to any one of the above embodiments.
[0135] Embodiment three:
[0136] The application also provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the steps of the method according to the above embodiments.
[0137] The modules / cells integrated by the computer unit, if realized in the form of software function units and sold or used as independent products, can be stored in a computer-readable storage medium. Based on such understanding, all or part of the processes of the above-mentioned embodiments can also be completed by a computer program instructing related hardware, and the computer program can be stored in a computer-readable storage medium. The computer program can implement the steps of each method embodiment when executed by a processor. The computer program includes computer program code, which can be in the form of source code, object code, executable files or some intermediate forms, etc. The computer-readable medium can include any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, magnetic disk, optical disk, computer memory, read-only memory (ROM), random access memory (RAM) and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0138] Embodiment four:
[0139] The application also provides a computer program product comprising a computer program, wherein the computer program is executed by a processor to implement the steps of the method as described above.
[0140] Although the present application has been particularly shown and described with respect to preferred embodiments thereof, it will be understood by those skilled in the art that various changes in form and details can be made therein without departing from the spirit and scope of the application as defined in the appended claims.
Claims
1. A method for Three.js-based BIM model rendering and component positioning, characterized in that, The method comprises the following steps: Merging a plurality of independent components in the imported BIM model that meet predetermined merging conditions into a whole model, and saving the coordinates of the bounding box of each independent component in the plurality of independent components; Using an octree to divide the space of the BIM model into a plurality of subspaces and generating a plurality of nodes corresponding to the plurality of subspaces; According to the coordinates of the bounding box of each independent component in the plurality of independent components and the subspaces corresponding to the octree nodes, each independent component in the plurality of independent components is assigned to the corresponding octree node; After the BIM model is loaded into the front-end display, in response to a click on the whole model, the screen coordinates of the click point corresponding to the click are determined, and the screen coordinates are converted into the three-dimensional space coordinates of the click point in the BIM model; According to the three-dimensional space coordinates of the click point in the BIM model, the minimum octree node in which the click point belongs is determined, and the subspace of the minimum octree node is the smallest; Among the at least one independent component contained in the minimum octree node, the independent component whose bounding box contains the click point is determined as the target component corresponding to the click; The step of using an octree to divide the space of the BIM model into a plurality of subspaces and generating a plurality of nodes corresponding to the plurality of subspaces comprises the following steps: The global space of the BIM model is initialized as the root node of the octree; Starting from the global space, recursively divide the space into eight subspaces according to the center point and generate eight child nodes corresponding to the eight subspaces, until the number of independent components contained in the subspace is less than or equal to a predetermined number, and stop dividing the subspace; wherein each octree node records: the boundary of the node itself, the identification of the parent node of the node itself, the identification of the child node of the node itself, the depth of the current node and the information of the contained component, the information of the component including: component identification and the coordinates of the component bounding box.
2. The method of claim 1, wherein, After determining the target component corresponding to the click, the method further comprises the following steps: Returning the information of the target component to the front end.
3. The method of claim 1, wherein, The step of merging the plurality of independent components into a whole model comprises the following steps: Obtaining the world coordinates of each independent component in the plurality of independent components in the world coordinate system; According to the world coordinates of each independent component in the world coordinate system, the plurality of independent components are merged to generate a merged component corresponding to the whole model; According to the merged component, a Mesh object corresponding to the whole model is generated; Adding the Mesh object to the selected scene to replace the plurality of independent components in the selected scene.
4. The method of claim 3, wherein, After adding the Mesh object to the selected scene, the method further comprises the following steps: Removing the plurality of independent components.
5. The method of claim 1, wherein, The plurality of independent components have a unified material before being merged.
6. The method of claim 3, wherein, The step of converting the screen coordinates into the three-dimensional space coordinates of the click point in the BIM model comprises the following steps: Normalizing the screen coordinates to obtain normalized coordinates; Using the Raycaster class of Three.js to map the normalized coordinates to a camera frustum to generate a ray, the ray extends along the direction from the camera to the three-dimensional space; The Raycaster is used to detect the intersection of the ray and the Mesh object by using the intersectObject or intersectObjects method to obtain the position coordinates of the intersection point and the object information intersecting with the intersection point; wherein the position coordinates of the intersection point are determined as the three-dimensional space coordinates of the click point.
7. An electronic device, comprising: The memory stores at least one program, and the processor executes the at least one program to implement the method for rendering and positioning a BIM model based on Three.js according to any one of claims 1 to 6.
8. A computer-readable storage medium, characterized in that, The storage medium stores at least one program, and the processor executes the at least one program to implement the method for rendering and positioning a BIM model based on Three.js according to any one of claims 1 to 6.
9. A computer program product comprising a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the method for rendering and positioning a BIM model based on Three.js according to any one of claims 1 to 6.
Citation Information
Patent Citations
Three-dimensional model plane pickup method and system based on position coding octree
CN116188685A
Method for calculating construction progress of each component based on surveying and mapping point cloud and BIM model
CN117808866A