HitscanWeapon

@three-blocks/proPhysicsWeaponsHitscanWebGPUWebGL
new HitscanWeapon(views : Object, type : string, index : number, mesh : THREE.Mesh, physics : Physics, properties : Object)
Extends
Weapon

HitscanWeapon - Hitscan weapon proxy extension

Extends the base Weapon class with hitscan-specific properties like max distance and piercing. Hitscan weapons use instant raycasting for hit detection (no physics-based projectile).

Constructor Parameters
viewsObject
SharedArrayBuffer views
typestring
Weapon type
indexnumber
Weapon slot index
meshTHREE.Mesh
Visual mesh (usually null for hitscan)
Physics instance reference
propertiesObject
Weapon configuration properties
Example
import { Physics, WeaponType, WeaponEvent } from '@three-blocks/pro';

const rifle = await physics.addWeapon(WeaponType.HITSCAN, null, {
  damage: 25,
  maxDistance: 1000,
  piercing: false,
});

rifle.weapon.addEventListener(WeaponEvent.HIT, (event) => {
  drawBulletHole(event.hitPoint, event.hitNormal);
});

rifle.weapon.fireFromCamera();

Properties

.maxDistance : number

Get maximum raycast distance.

.maxDistance : number

Set maximum raycast distance.

.piercing : boolean

Get piercing flag (shoot through multiple targets).

.piercing : boolean

Set piercing flag (shoot through multiple targets).