-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: improve camera for movements + init capsule polyhedron
- Loading branch information
1 parent
6f1a43c
commit d08e8a7
Showing
7 changed files
with
149 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import * as THREE from 'three' | ||
import type * as RAPIER from '@dimforge/rapier3d' | ||
import type { FScene3d } from '../FScene3d' | ||
import { F3dShapes } from '../types/F3dShapes' | ||
import { FPolyhedron } from './FPolyhedron' | ||
|
||
/** | ||
* @description A simple capsule model in FibboJS. | ||
* @category Model | ||
* @example | ||
* ```ts | ||
* import { FScene3d, FCapsule } from '@fibbojs/3d' | ||
* | ||
* const scene = new FScene3d() | ||
* | ||
* const capsule = new FCapsule(scene) | ||
* scene.addComponent(capsule) | ||
* ``` | ||
*/ | ||
export class FCapsule extends FPolyhedron { | ||
constructor(scene: FScene3d, options?: { | ||
position?: { x: number, y: number, z: number } | ||
scale?: { x: number, y: number, z: number } | ||
rotation?: { x: number, y: number, z: number } | ||
rotationDegree?: { x: number, y: number, z: number } | ||
}) { | ||
super(scene, options) | ||
// Create a capsule | ||
const geometry = new THREE.CapsuleGeometry(0.5, 1, 32) | ||
const material = new THREE.MeshBasicMaterial({ color: 0x666666 }) | ||
this.mesh = new THREE.Mesh(geometry, material) | ||
} | ||
|
||
onFrame(_delta: number): void { | ||
super.onFrame(_delta) | ||
} | ||
|
||
initRigidBody(options?: { | ||
position?: THREE.Vector3 | ||
scale?: THREE.Vector3 | ||
rotation?: THREE.Vector3 | ||
shape?: F3dShapes | ||
rigidBodyType?: RAPIER.RigidBodyType | ||
lockTranslations?: boolean | ||
lockRotations?: boolean | ||
enabledTranslations?: { | ||
enableX: boolean | ||
enableY: boolean | ||
enableZ: boolean | ||
} | ||
enabledRotations?: { | ||
enableX: boolean | ||
enableY: boolean | ||
enableZ: boolean | ||
} | ||
}): void { | ||
super.initRigidBody({ | ||
...options, | ||
shape: F3dShapes.CAPSULE, | ||
}) | ||
} | ||
|
||
initCollider(options?: { | ||
position?: THREE.Vector3 | ||
scale?: THREE.Vector3 | ||
rotation?: THREE.Vector3 | ||
shape?: F3dShapes | ||
}): void { | ||
super.initCollider({ | ||
...options, | ||
shape: F3dShapes.CAPSULE, | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,4 +2,6 @@ | |
export enum F3dShapes { | ||
CUBE = 'Cube', | ||
SPHERE = 'Sphere', | ||
CAPSULE = 'Capsule', | ||
MESH = 'Mesh', | ||
} |