{"record":{"id":"a93a6b132d6aefc0","repo":"BabylonJS/Babylon.js","slug":"the-webgl2particlesystem-class-is-not-available-m","errorCode":null,"errorMessage":"The WebGL2ParticleSystem class is not available! Make sure you have imported it.","messagePattern":"The WebGL2ParticleSystem class is not available! Make sure you have imported it\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/dev/core/src/Particles/gpuParticleSystem.pure.ts","lineNumber":1103,"sourceCode":"        if (!sceneOrEngine || sceneOrEngine.getClassName() === \"Scene\") {\r\n            this._scene = (sceneOrEngine as Scene) || EngineStore.LastCreatedScene;\r\n            this._engine = this._scene.getEngine();\r\n            this.uniqueId = this._scene.getUniqueId();\r\n            this.layerMask = this._scene.defaultRenderableLayerMask;\r\n            this._scene.particleSystems.push(this);\r\n        } else {\r\n            this._engine = sceneOrEngine as AbstractEngine;\r\n            this.defaultProjectionMatrix = Matrix.PerspectiveFovLH(0.8, 1, 0.1, 100, this._engine.isNDCHalfZRange);\r\n        }\r\n\r\n        if (this._engine.getCaps().supportComputeShaders) {\r\n            if (!GetClass(\"BABYLON.ComputeShaderParticleSystem\")) {\r\n                throw new Error(\"The ComputeShaderParticleSystem class is not available! Make sure you have imported it.\");\r\n            }\r\n            this._platform = new (GetClass(\"BABYLON.ComputeShaderParticleSystem\"))(this, this._engine);\r\n        } else {\r\n            if (!GetClass(\"BABYLON.WebGL2ParticleSystem\")) {\r\n                throw new Error(\"The WebGL2ParticleSystem class is not available! Make sure you have imported it.\");\r\n            }\r\n            this._platform = new (GetClass(\"BABYLON.WebGL2ParticleSystem\"))(this, this._engine);\r\n        }\r\n\r\n        this._customWrappers = { 0: new DrawWrapper(this._engine) };\r\n        this._customWrappers[0]!.effect = customEffect;\r\n\r\n        this._drawWrappers = { 0: new DrawWrapper(this._engine) };\r\n        if (this._drawWrappers[0].drawContext) {\r\n            this._drawWrappers[0].drawContext.useInstancing = true;\r\n        }\r\n\r\n        this._createIndexBuffer();\r\n\r\n        // Setup the default processing configuration to the scene.\r\n        this._attachImageProcessingConfiguration(null);\r\n\r\n        options = options ?? {};\r","sourceCodeStart":1085,"sourceCodeEnd":1121,"githubUrl":"https://github.com/BabylonJS/Babylon.js/blob/0592b347b8a4ee0236089ea86a749cacfdb266d8/packages/dev/core/src/Particles/gpuParticleSystem.pure.ts#L1085-L1121","documentation":"On engines without compute shader support, GPUParticleSystem uses the WebGL2 update pipeline, looked up as registered class \"BABYLON.WebGL2ParticleSystem\". That class is registered by a separate module import; if it wasn't imported (common with ES6 tree-shaken imports), GetClass returns undefined and the constructor throws.","triggerScenarios":"Constructing new GPUParticleSystem(...) on a WebGL2/limitless engine (supportComputeShaders false) while the module registering WebGL2ParticleSystem was never imported.","commonSituations":"Importing GPUParticleSystem from a deep/pure module path in an ES6 project without the webgl2ParticleSystem side-effect import; standard WebGL2 apps that tree-shake away the registration.","solutions":["Add the side-effect import registering WebGL2ParticleSystem (import the package index or the webgl2ParticleSystem module).","Import from \"@babylonjs/core\" full bundle instead of deep paths.","Check bundler config isn't dropping side-effect imports (sideEffects flag / sideEffects:false in package resolution)."],"exampleFix":"// before\nimport { GPUParticleSystem } from \"@babylonjs/core/Particles/gpuParticleSystem\";\n// after\nimport \"@babylonjs/core/Particles/webgl2ParticleSystem\";\nimport { GPUParticleSystem } from \"@babylonjs/core/Particles/gpuParticleSystem\";","handlingStrategy":"validation","validationCode":"if (!engine.getCaps().supportComputeShaders) {\n  import(\"@babylonjs/core/Particles/webgl2ParticleSystem\"); // ensure registered\n}","typeGuard":null,"tryCatchPattern":"try {\n  const ps = new GPUParticleSystem(\"p\", { capacity: 1000 }, engine);\n} catch (e) {\n  if (e.message.includes(\"WebGL2ParticleSystem\")) {\n    console.error(\"Add: import \\\"@babylonjs/core/Particles/webgl2ParticleSystem\\\";\");\n  }\n}","preventionTips":["Prefer importing from the package root over deep/pure module paths.","When tree-shaking, keep registration side-effect imports next to usage.","Test GPU particles in the final bundler build, not just dev server."],"tags":["gpu-particles","webgl2","missing-import","side-effect-module"],"backgroundTag":"class-not-registered-missing-import","analyzedSha":"0592b347b8a4ee0236089ea86a749cacfdb266d8","analyzedAt":"2026-08-30T15:11:20.442Z","schemaVersion":2},"datasetVersion":"2026-08-30T18:17:15.746Z"}