CannonCylinder.re.ts 794 B

12345678910111213141516171819202122232425262728
  1. import * as RE from 'rogue-engine';
  2. import * as THREE from 'three';
  3. import * as CANNON from 'cannon-es';
  4. import CannonShape from './CannonShape';
  5. export default class CannonCylinder extends CannonShape {
  6. shape: CANNON.Cylinder;
  7. @RE.Prop("Number") radiusTopOffset = 1;
  8. @RE.Prop("Number") radiusBottomOffset = 1;
  9. @RE.Prop("Number") heightOffset = 1;
  10. @RE.Prop("Number") segments = 100;
  11. worldScale = new THREE.Vector3();
  12. protected createShape() {
  13. this.object3d.getWorldScale(this.worldScale);
  14. this.shape = new CANNON.Cylinder(
  15. this.radiusTopOffset * this.worldScale.x,
  16. this.radiusBottomOffset * this.worldScale.x,
  17. this.heightOffset * this.worldScale.y,
  18. this.segments
  19. );
  20. }
  21. }
  22. RE.registerComponent(CannonCylinder);