{"record":{"id":"698cc0ca445c11ce","repo":"BabylonJS/Babylon.js","slug":"point-cloud-system-doesnt-contain-the-mesh","errorCode":null,"errorMessage":"Point Cloud System doesnt contain the Mesh","messagePattern":"Point Cloud System doesnt contain the Mesh","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Particles/cloudPoint.ts","lineNumber":153,"sourceCode":"     */\r\n    public set quaternion(q: Nullable<Quaternion>) {\r\n        this.rotationQuaternion = q;\r\n    }\r\n\r\n    /**\r\n     * Returns a boolean. True if the particle intersects a mesh, else false\r\n     * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere\r\n     * @param target is the object (point or mesh) what the intersection is computed against\r\n     * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bounding sphere is used\r\n     * @returns true if it intersects\r\n     */\r\n    public intersectsMesh(target: Mesh, isSphere: boolean): boolean {\r\n        if (!target.hasBoundingInfo) {\r\n            return false;\r\n        }\r\n\r\n        if (!this._pcs.mesh) {\r\n            throw new Error(\"Point Cloud System doesnt contain the Mesh\");\r\n        }\r\n\r\n        if (isSphere) {\r\n            return target.getBoundingInfo().boundingSphere.intersectsPoint(this.position.add(this._pcs.mesh.position));\r\n        }\r\n\r\n        const bbox = target.getBoundingInfo().boundingBox;\r\n\r\n        const maxX = bbox.maximumWorld.x;\r\n        const minX = bbox.minimumWorld.x;\r\n        const maxY = bbox.maximumWorld.y;\r\n        const minY = bbox.minimumWorld.y;\r\n        const maxZ = bbox.maximumWorld.z;\r\n        const minZ = bbox.minimumWorld.z;\r\n\r\n        const x = this.position.x + this._pcs.mesh.position.x;\r\n        const y = this.position.y + this._pcs.mesh.position.y;\r\n        const z = this.position.z + this._pcs.mesh.position.z;\r","sourceCodeStart":135,"sourceCodeEnd":171,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Particles/cloudPoint.ts#L135-L171","documentation":"CloudPoint.intersectsMesh tests whether the point intersects a target mesh. The intersection math positions the point in world space using the owning PointCloudSystem's mesh, so the PCS must have a mesh assigned. If this._pcs.mesh is null (the PCS was created without ever setting/finalizing its mesh), the point cannot be transformed and the method throws.","triggerScenarios":"Calling cloudPoint.intersectsMesh(target, isSphere) on a point from a PointCloudSystem whose `mesh` property is null — e.g. before buildMeshAsync() completes or on a PCS used purely as a data container.","commonSituations":"Querying intersections immediately after creating a PointCloudSystem but before awaiting buildMeshAsync(); or after explicitly clearing/disposing the mesh; or on PCS instances used only for point storage.","solutions":["Await pcs.buildMeshAsync() before calling intersectsMesh.","Check pcs.mesh for null before intersecting and skip/handle the case.","If the PCS is data-only, convert to a real mesh-based PCS or compute intersection manually from the point position."],"exampleFix":"// before\nconst hit = point.intersectsMesh(box, false);\n// after\nawait pcs.buildMeshAsync();\nconst hit = pcs.mesh ? point.intersectsMesh(box, false) : false;","handlingStrategy":"validation","validationCode":"if (!pcs.mesh) throw new Error(\"Call await pcs.buildMeshAsync() before intersect tests\");","typeGuard":"function pcsHasMesh(pcs: PointCloudSystem): boolean {\n  return pcs.mesh !== null;\n}","tryCatchPattern":"try {\n  const hit = point.intersectsMesh(target, false);\n} catch (e) {\n  if (e.message.includes(\"doesnt contain the Mesh\")) {\n    await pcs.buildMeshAsync(); // then retry or skip\n  } else throw e;\n}","preventionTips":["Always await buildMeshAsync() before any mesh-dependent queries.","Check pcs.mesh != null in shared utility code.","Keep data-only point clouds separate from ones used for intersection."],"tags":["point-cloud","mesh","null-reference"],"backgroundTag":"mesh-not-initialized","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}