Skip to content

Commit

Permalink
fix: mini fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Gugustinette committed Aug 27, 2024
1 parent d3bdfa9 commit b244883
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
4 changes: 3 additions & 1 deletion apps/playground-3d/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ import MyCustomCube from './classes/MyCustomCube'
scene.addComponent(ground2)

// Create a character
const character = new FCharacter3dKP(scene)
const character = new FCharacter3dKP(scene, {
position: { x: 0, y: 10, z: 0 },
})
scene.addComponent(character)

// Attach a camera to the character
Expand Down
22 changes: 13 additions & 9 deletions packages/3d/src/FComponent3d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export abstract class FComponent3d extends FComponent {
this.rotation.set(newMeshRotation.x, newMeshRotation.y, newMeshRotation.z)
// If a sensor exists, update its position and rotation according to the rigid body
if (this.sensor) {
// Apply offset to the sensor
newMeshPosition.x += this.sensor.colliderPositionOffset.x
newMeshPosition.y += this.sensor.colliderPositionOffset.y
newMeshPosition.z += this.sensor.colliderPositionOffset.z
this.sensor.collider.setTranslation(newMeshPosition)
this.sensor.collider.setRotation(new THREE.Quaternion(newMeshRotation.x, newMeshRotation.y, newMeshRotation.z, newMeshRotation.w))
}
Expand Down Expand Up @@ -274,9 +278,9 @@ export abstract class FComponent3d extends FComponent {
* @example
* ```ts
* component.initRigidBody({
* position: new THREE.Vector3(0, 1, 0),
* scale: new THREE.Vector3(1, 1, 1),
* rotation: new THREE.Vector3(0, 0, 0),
* position: { x: 0, y: 0, z: 0 },
* scale: { x: 1, y: 1, z: 1 },
* rotation: { x: 0, y: 0, z: 0 },
* shape: F3dShapes.CUBE
* })
* ```
Expand All @@ -303,9 +307,9 @@ export abstract class FComponent3d extends FComponent {
* @example
* ```ts
* component.initCollider({
* position: new THREE.Vector3(0, 1, 0),
* scale: new THREE.Vector3(1, 1, 1),
* rotation: new THREE.Vector3(0, 0, 0),
* position: { x: 0, y: 0, z: 0 },
* scale: { x: 1, y: 1, z: 1 },
* rotation: { x: 0, y: 0, z: 0 },
* shape: F3dShapes.CUBE
* })
* ```
Expand All @@ -327,9 +331,9 @@ export abstract class FComponent3d extends FComponent {
* @example
* ```ts
* component.initSensor({
* position: new THREE.Vector3(0, 1, 0),
* scale: new THREE.Vector3(1, 1, 1),
* rotation: new THREE.Vector3(0, 0, 0),
* position: { x: 0, y: 0, z: 0 },
* scale: { x: 1, y: 1, z: 1 },
* rotation: { x: 0, y: 0, z: 0 },
* shape: F3dShapes.CUBE
* })
* ```
Expand Down

0 comments on commit b244883

Please sign in to comment.