ecspresso
    Preparing search index...
    • Create a 3D spatial index plugin for ECSpresso.

      Provides a uniform-grid spatial hash that accelerates 3D collision detection. When installed alongside the collision3D or physics3D plugins, they automatically use the spatial index for broadphase instead of O(n²) brute-force.

      Also provides proximity query methods for game logic (e.g. "find all enemies within 200 units").

      Type Parameters

      • G extends string = "spatialIndex3D"

      Parameters

      Returns Plugin<
          WithResources<
              WithComponents<EmptyConfig, SpatialIndex3DComponentTypes>,
              SpatialIndex3DResourceTypes,
          >,
          EmptyConfig,

              | "spatial-index3D-rebuild-fixedUpdate"
              | "spatial-index3D-rebuild-postUpdate",
          G,
          never,
          never,
      >

      const ecs = ECSpresso.create()
      .withPlugin(createTransform3DPlugin())
      .withPlugin(createCollision3DPlugin({ layers }))
      .withPlugin(createSpatialIndex3DPlugin({ cellSize: 128 }))
      .build();

      // Proximity query in a system:
      const si = ecs.getResource('spatialIndex3D');
      const nearby = si.queryRadius(playerX, playerY, playerZ, 200);