From 80b6fdf057f7308259e47b328813060ab5ca7088 Mon Sep 17 00:00:00 2001 From: Gugustinette Date: Thu, 1 Aug 2024 23:15:25 +0200 Subject: [PATCH] Improve initRigidBody and initCollider API (parameters trully optional) --- apps/playground-2d/src/main.ts | 13 ++- apps/playground-3d/src/classes/MyCube.ts | 16 --- apps/playground-3d/src/classes/MySphere.ts | 14 --- apps/playground-3d/src/main.ts | 59 ++++++++++- docs/api/2d/classes/FCircle.md | 90 +++++++++-------- docs/api/2d/classes/FComponent2d.md | 90 +++++++++-------- docs/api/2d/classes/FScene2d.md | 28 +++--- docs/api/2d/classes/FSprite.md | 104 ++++++++++--------- docs/api/2d/classes/FSquare.md | 90 +++++++++-------- docs/api/2d/enumerations/F2dShapes.md | 4 +- docs/api/3d/classes/FAttachedCamera.md | 14 +-- docs/api/3d/classes/FCamera3d.md | 10 +- docs/api/3d/classes/FComponent3d.md | 85 +++++++++------- docs/api/3d/classes/FCube.md | 87 +++++++++------- docs/api/3d/classes/FFixedCamera.md | 10 +- docs/api/3d/classes/FGLTF.md | 93 +++++++++-------- docs/api/3d/classes/FGameCamera.md | 14 +-- docs/api/3d/classes/FOrbitCamera.md | 14 +-- docs/api/3d/classes/FPolyhedron.md | 87 +++++++++------- docs/api/3d/classes/FScene3d.md | 26 ++--- docs/api/3d/classes/FSphere.md | 89 ++++++++++------- docs/api/3d/enumerations/F3dShapes.md | 4 +- docs/api/core/classes/FCamera.md | 4 +- docs/api/core/classes/FComponent.md | 4 +- docs/api/core/classes/FGroup.md | 10 +- docs/api/core/classes/FScene.md | 16 +-- packages/2d/src/FComponent2d.ts | 110 +++++++++++++-------- packages/2d/src/FScene2d.ts | 7 -- packages/2d/src/polygons/FCircle.ts | 34 ++++--- packages/3d/src/FComponent3d.ts | 105 +++++++++++++------- packages/3d/src/model/FSphere.ts | 29 ++++-- 31 files changed, 780 insertions(+), 580 deletions(-) delete mode 100644 apps/playground-3d/src/classes/MyCube.ts delete mode 100644 apps/playground-3d/src/classes/MySphere.ts diff --git a/apps/playground-2d/src/main.ts b/apps/playground-2d/src/main.ts index 59e822d1..9a68781d 100644 --- a/apps/playground-2d/src/main.ts +++ b/apps/playground-2d/src/main.ts @@ -1,5 +1,5 @@ import './style.css' -import { FCircle, FScene2d, FSprite, FSquare } from '@fibbojs/2d' +import { F2dShapes, FCircle, FScene2d, FSprite, FSquare } from '@fibbojs/2d' import MySquare from './classes/MySquare' (async () => { @@ -7,6 +7,13 @@ import MySquare from './classes/MySquare' await scene.init() await scene.initPhysics() + // Create the ground + const ground = new FSquare(scene) + ground.setPosition(0, 0) + ground.setScale(10, 0.1) + ground.initCollider() + scene.addComponent(ground) + const square = new MySquare(scene) scene.addComponent(square) @@ -19,7 +26,9 @@ import MySquare from './classes/MySquare' const square3 = new FSquare(scene) square3.setPosition(4, 1) - square3.initCollider() + square3.initCollider({ + shape: F2dShapes.CIRCLE, + }) scene.addComponent(square3) const square4 = new FSquare(scene) diff --git a/apps/playground-3d/src/classes/MyCube.ts b/apps/playground-3d/src/classes/MyCube.ts deleted file mode 100644 index e4a96016..00000000 --- a/apps/playground-3d/src/classes/MyCube.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { FCube } from '@fibbojs/3d' -import type { FScene3d } from '@fibbojs/3d' - -export default class MyCube extends FCube { - constructor(scene: FScene3d) { - super(scene) - this.setPosition(4, 5, -2) - this.setScale(2, 0.5, 1) - this.setRotationDegree(60, 0, 0) - this.initRigidBody() - } - - onFrame(delta: number) { - super.onFrame(delta) - } -} diff --git a/apps/playground-3d/src/classes/MySphere.ts b/apps/playground-3d/src/classes/MySphere.ts deleted file mode 100644 index 44d46103..00000000 --- a/apps/playground-3d/src/classes/MySphere.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { FSphere } from '@fibbojs/3d' -import type { FScene3d } from '@fibbojs/3d' - -export default class MySphere extends FSphere { - constructor(scene: FScene3d) { - super(scene) - this.setPosition(-2, 3, -2) - this.initRigidBody() - } - - onFrame(delta: number) { - super.onFrame(delta) - } -} diff --git a/apps/playground-3d/src/main.ts b/apps/playground-3d/src/main.ts index a67c93ff..cdf60c1b 100644 --- a/apps/playground-3d/src/main.ts +++ b/apps/playground-3d/src/main.ts @@ -1,9 +1,11 @@ +import { F3dShapes, FCube, FGameCamera, FScene3d, FSphere } from '@fibbojs/3d' +import Duck from './classes/Duck' +import GltfCube from './classes/GltfCube' import './style.css' -import { FCube, FGameCamera, FScene3d } from '@fibbojs/3d' (async () => { // Initialize the scene - const scene = new FScene3d() + const scene = new FScene3d({ debug: true }) await scene.init() await scene.initPhysics() @@ -17,9 +19,60 @@ import { FCube, FGameCamera, FScene3d } from '@fibbojs/3d' // Create a cube const cube = new FCube(scene) - cube.initRigidBody() + cube.setColor(0xA0FFA0) + cube.setPosition(-5, 5, 5) + cube.initRigidBody({ + shape: F3dShapes.SPHERE, + }) scene.addComponent(cube) + const sphere = new FSphere(scene) + sphere.setPosition(2, 4, -2) + sphere.initRigidBody() + scene.addComponent(sphere) + + const duck = new Duck(scene) + scene.addComponent(duck) + + const gltfCube = new GltfCube(scene) + scene.addComponent(gltfCube) + + // Create 8 cubes dynamically in circle from 0 to 2PI + for (let i = 0; i < 8; i++) { + const angle = i * Math.PI / 4 + const x = Math.cos(angle) * 4 + const z = Math.sin(angle) * 4 + const cube = new FCube(scene) + cube.setPosition(x, 1, z) + cube.initRigidBody() + scene.addComponent(cube) + } + + scene.camera = new FGameCamera(gltfCube, scene) + + // Detect inputs to move the cube + document.addEventListener('keydown', (event) => { + const impulse = { x: 0, y: 0, z: 0 } + switch (event.key) { + case 'ArrowUp': + impulse.z = -1 + break + case 'ArrowDown': + impulse.z = 1 + break + case 'ArrowLeft': + impulse.x = -1 + break + case 'ArrowRight': + impulse.x = 1 + break + case ' ': + cube.rigidBody?.applyImpulse({ x: 0, y: 5, z: 0 }, true) + break + } + cube.rigidBody?.applyImpulse(impulse, true) + }) + // Attach a camera to the cube scene.camera = new FGameCamera(cube, scene) })() diff --git a/docs/api/2d/classes/FCircle.md b/docs/api/2d/classes/FCircle.md index 9be60ed5..9e2bc1eb 100644 --- a/docs/api/2d/classes/FCircle.md +++ b/docs/api/2d/classes/FCircle.md @@ -41,29 +41,33 @@ scene.addComponent(circle) #### Defined in -[packages/2d/src/polygons/FCircle.ts:20](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FCircle.ts#L20) +[packages/2d/src/polygons/FCircle.ts:20](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FCircle.ts#L20) ## Methods ### initCollider() -> **initCollider**(`position`?, `scale`?, `rotation`?, `shape`?): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position?**: `PointData` +• **options?** -The position of the collider. +The options for the collider. -• **scale?**: `PointData` +• **options.position?**: `PointData` -The scale of the collider. +The position of the collider. -• **rotation?**: `number` +• **options.rotation?**: `number` The rotation of the collider. -• **shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.CIRCLE` +• **options.scale?**: `PointData` + +The scale of the collider. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the collider. @@ -79,12 +83,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initCollider({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Overrides @@ -93,29 +97,33 @@ component.initCollider( #### Defined in -[packages/2d/src/polygons/FCircle.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FCircle.ts#L41) +[packages/2d/src/polygons/FCircle.ts:44](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FCircle.ts#L44) *** ### initRigidBody() -> **initRigidBody**(`position`?, `scale`?, `rotation`?, `shape`?): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position?**: `PointData` +• **options?** -The position of the rigid body. +The options for the rigid body. -• **scale?**: `PointData` +• **options.position?**: `PointData` -The scale of the rigid body. +The position of the rigid body. -• **rotation?**: `number` +• **options.rotation?**: `number` The rotation of the rigid body. -• **shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.CIRCLE` +• **options.scale?**: `PointData` + +The scale of the rigid body. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the rigid body. @@ -130,12 +138,12 @@ Init a rigid body for the model. #### Example ```ts -component.initRigidBody( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initRigidBody({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Overrides @@ -144,7 +152,7 @@ component.initRigidBody( #### Defined in -[packages/2d/src/polygons/FCircle.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FCircle.ts#L32) +[packages/2d/src/polygons/FCircle.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FCircle.ts#L32) *** @@ -171,7 +179,7 @@ Should be called every frame. #### Defined in -[packages/2d/src/polygons/FCircle.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FCircle.ts#L28) +[packages/2d/src/polygons/FCircle.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FCircle.ts#L28) *** @@ -209,7 +217,7 @@ component.setPosition(0, 0) #### Defined in -[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L100) +[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L100) *** @@ -243,7 +251,7 @@ component.setRotation(Math.PI / 2) #### Defined in -[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L131) +[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L131) *** @@ -277,7 +285,7 @@ component.setRotationDegree(90) #### Defined in -[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L144) +[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L144) *** @@ -315,7 +323,7 @@ component.setScale(1, 1) #### Defined in -[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L114) +[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L114) ## Properties @@ -331,7 +339,7 @@ RAPIER Collider #### Defined in -[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L46) +[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L46) *** @@ -347,7 +355,7 @@ PIXI container #### Defined in -[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L22) +[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L22) *** @@ -363,7 +371,7 @@ Position of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L28) +[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L28) *** @@ -379,7 +387,7 @@ RAPIER RigidBody #### Defined in -[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L42) +[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L42) *** @@ -395,7 +403,7 @@ Rotation of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L36) +[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L36) *** @@ -411,7 +419,7 @@ Scale of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L32) +[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L32) *** @@ -427,4 +435,4 @@ The scene which the component is in. #### Defined in -[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L17) +[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L17) diff --git a/docs/api/2d/classes/FComponent2d.md b/docs/api/2d/classes/FComponent2d.md index d73c1f1a..635d5fa5 100644 --- a/docs/api/2d/classes/FComponent2d.md +++ b/docs/api/2d/classes/FComponent2d.md @@ -38,29 +38,33 @@ The 2D scene where the component will be added. #### Defined in -[packages/2d/src/FComponent2d.ts:51](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L51) +[packages/2d/src/FComponent2d.ts:51](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L51) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the collider. +The options for the collider. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the collider. +The position of the collider. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the collider. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the collider. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the collider. @@ -76,39 +80,43 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initCollider({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Defined in -[packages/2d/src/FComponent2d.ts:205](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L205) +[packages/2d/src/FComponent2d.ts:219](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L219) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the rigid body. +The options for the rigid body. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the rigid body. +The position of the rigid body. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the rigid body. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the rigid body. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the rigid body. @@ -123,17 +131,17 @@ Init a rigid body for the model. #### Example ```ts -component.initRigidBody( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initRigidBody({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Defined in -[packages/2d/src/FComponent2d.ts:164](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L164) +[packages/2d/src/FComponent2d.ts:165](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L165) *** @@ -160,7 +168,7 @@ Should be called every frame. #### Defined in -[packages/2d/src/FComponent2d.ts:68](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L68) +[packages/2d/src/FComponent2d.ts:68](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L68) *** @@ -194,7 +202,7 @@ component.setPosition(0, 0) #### Defined in -[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L100) +[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L100) *** @@ -224,7 +232,7 @@ component.setRotation(Math.PI / 2) #### Defined in -[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L131) +[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L131) *** @@ -254,7 +262,7 @@ component.setRotationDegree(90) #### Defined in -[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L144) +[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L144) *** @@ -288,7 +296,7 @@ component.setScale(1, 1) #### Defined in -[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L114) +[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L114) ## Properties @@ -300,7 +308,7 @@ RAPIER Collider #### Defined in -[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L46) +[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L46) *** @@ -312,7 +320,7 @@ PIXI container #### Defined in -[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L22) +[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L22) *** @@ -324,7 +332,7 @@ Position of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L28) +[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L28) *** @@ -336,7 +344,7 @@ RAPIER RigidBody #### Defined in -[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L42) +[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L42) *** @@ -348,7 +356,7 @@ Rotation of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L36) +[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L36) *** @@ -360,7 +368,7 @@ Scale of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L32) +[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L32) *** @@ -372,4 +380,4 @@ The scene which the component is in. #### Defined in -[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L17) +[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L17) diff --git a/docs/api/2d/classes/FScene2d.md b/docs/api/2d/classes/FScene2d.md index 39e9be50..b94f8067 100644 --- a/docs/api/2d/classes/FScene2d.md +++ b/docs/api/2d/classes/FScene2d.md @@ -48,7 +48,7 @@ import { FScene2d, FSquare } from '@fibbojs/2d' #### Defined in -[packages/2d/src/FScene2d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L42) +[packages/2d/src/FScene2d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L42) ## Methods @@ -74,7 +74,7 @@ Add a component to the scene. #### Defined in -[packages/2d/src/FScene2d.ts:168](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L168) +[packages/2d/src/FScene2d.ts:161](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L161) *** @@ -88,7 +88,7 @@ Add a component to the scene. #### Defined in -[packages/2d/src/FScene2d.ts:203](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L203) +[packages/2d/src/FScene2d.ts:196](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L196) *** @@ -109,7 +109,7 @@ and the root stage PIXI.Container. #### Defined in -[packages/2d/src/FScene2d.ts:63](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L63) +[packages/2d/src/FScene2d.ts:63](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L63) *** @@ -123,7 +123,7 @@ and the root stage PIXI.Container. #### Defined in -[packages/2d/src/FScene2d.ts:144](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L144) +[packages/2d/src/FScene2d.ts:144](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L144) *** @@ -167,7 +167,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/2d/src/FScene2d.ts:199](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L199) +[packages/2d/src/FScene2d.ts:192](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L192) ## Properties @@ -177,7 +177,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/2d/src/FScene2d.ts:38](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L38) +[packages/2d/src/FScene2d.ts:38](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L38) *** @@ -187,7 +187,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/2d/src/FScene2d.ts:40](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L40) +[packages/2d/src/FScene2d.ts:40](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L40) *** @@ -197,7 +197,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/2d/src/FScene2d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L31) +[packages/2d/src/FScene2d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L31) *** @@ -225,7 +225,7 @@ packages/core/dist/index.d.ts:62 #### Defined in -[packages/2d/src/FScene2d.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L28) +[packages/2d/src/FScene2d.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L28) *** @@ -251,7 +251,7 @@ packages/core/dist/index.d.ts:62 #### Defined in -[packages/2d/src/FScene2d.ts:34](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L34) +[packages/2d/src/FScene2d.ts:34](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L34) *** @@ -275,7 +275,7 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/2d/src/FScene2d.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L36) +[packages/2d/src/FScene2d.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L36) *** @@ -285,7 +285,7 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/2d/src/FScene2d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L32) +[packages/2d/src/FScene2d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L32) *** @@ -299,4 +299,4 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/2d/src/FScene2d.ts:29](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FScene2d.ts#L29) +[packages/2d/src/FScene2d.ts:29](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FScene2d.ts#L29) diff --git a/docs/api/2d/classes/FSprite.md b/docs/api/2d/classes/FSprite.md index 9009e933..6338e1f9 100644 --- a/docs/api/2d/classes/FSprite.md +++ b/docs/api/2d/classes/FSprite.md @@ -43,7 +43,7 @@ scene.addComponent(sprite) #### Defined in -[packages/2d/src/sprite/FSprite.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L28) +[packages/2d/src/sprite/FSprite.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L28) ## Methods @@ -61,29 +61,33 @@ Emit the onLoaded callbacks. #### Defined in -[packages/2d/src/sprite/FSprite.ts:93](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L93) +[packages/2d/src/sprite/FSprite.ts:93](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L93) *** ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the collider. +The options for the collider. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the collider. +The position of the collider. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the collider. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the collider. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the collider. @@ -99,12 +103,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initCollider({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Inherited from @@ -113,29 +117,33 @@ component.initCollider( #### Defined in -[packages/2d/src/FComponent2d.ts:205](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L205) +[packages/2d/src/FComponent2d.ts:219](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L219) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the rigid body. +The options for the rigid body. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the rigid body. +The position of the rigid body. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the rigid body. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the rigid body. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the rigid body. @@ -150,12 +158,12 @@ Init a rigid body for the model. #### Example ```ts -component.initRigidBody( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initRigidBody({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Inherited from @@ -164,7 +172,7 @@ component.initRigidBody( #### Defined in -[packages/2d/src/FComponent2d.ts:164](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L164) +[packages/2d/src/FComponent2d.ts:165](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L165) *** @@ -188,7 +196,7 @@ Load a texture from a path. #### Defined in -[packages/2d/src/sprite/FSprite.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L46) +[packages/2d/src/sprite/FSprite.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L46) *** @@ -215,7 +223,7 @@ Should be called every frame. #### Defined in -[packages/2d/src/sprite/FSprite.ts:78](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L78) +[packages/2d/src/sprite/FSprite.ts:78](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L78) *** @@ -239,7 +247,7 @@ Add a callback to be called when the texture is loaded. #### Defined in -[packages/2d/src/sprite/FSprite.ts:86](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L86) +[packages/2d/src/sprite/FSprite.ts:86](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L86) *** @@ -277,7 +285,7 @@ component.setPosition(0, 0) #### Defined in -[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L100) +[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L100) *** @@ -311,7 +319,7 @@ component.setRotation(Math.PI / 2) #### Defined in -[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L131) +[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L131) *** @@ -345,7 +353,7 @@ component.setRotationDegree(90) #### Defined in -[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L144) +[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L144) *** @@ -383,7 +391,7 @@ component.setScale(1, 1) #### Defined in -[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L114) +[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L114) *** @@ -408,7 +416,7 @@ The width will be calculated according to the aspect ratio of the texture. #### Defined in -[packages/2d/src/sprite/FSprite.ts:74](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L74) +[packages/2d/src/sprite/FSprite.ts:74](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L74) *** @@ -433,7 +441,7 @@ The height will be calculated according to the aspect ratio of the texture. #### Defined in -[packages/2d/src/sprite/FSprite.ts:65](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L65) +[packages/2d/src/sprite/FSprite.ts:65](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L65) ## Properties @@ -449,7 +457,7 @@ RAPIER Collider #### Defined in -[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L46) +[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L46) *** @@ -465,7 +473,7 @@ PIXI container #### Defined in -[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L22) +[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L22) *** @@ -477,7 +485,7 @@ Callbacks for when the texture is loaded #### Defined in -[packages/2d/src/sprite/FSprite.ts:26](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L26) +[packages/2d/src/sprite/FSprite.ts:26](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L26) *** @@ -493,7 +501,7 @@ Position of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L28) +[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L28) *** @@ -509,7 +517,7 @@ RAPIER RigidBody #### Defined in -[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L42) +[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L42) *** @@ -525,7 +533,7 @@ Rotation of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L36) +[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L36) *** @@ -541,7 +549,7 @@ Scale of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L32) +[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L32) *** @@ -557,7 +565,7 @@ The scene which the component is in. #### Defined in -[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L17) +[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L17) *** @@ -569,4 +577,4 @@ The texture of the sprite. #### Defined in -[packages/2d/src/sprite/FSprite.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/sprite/FSprite.ts#L22) +[packages/2d/src/sprite/FSprite.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/sprite/FSprite.ts#L22) diff --git a/docs/api/2d/classes/FSquare.md b/docs/api/2d/classes/FSquare.md index 7530b12d..1230c32e 100644 --- a/docs/api/2d/classes/FSquare.md +++ b/docs/api/2d/classes/FSquare.md @@ -41,29 +41,33 @@ scene.addComponent(square) #### Defined in -[packages/2d/src/polygons/FSquare.ts:19](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FSquare.ts#L19) +[packages/2d/src/polygons/FSquare.ts:19](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FSquare.ts#L19) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the collider. +The options for the collider. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the collider. +The position of the collider. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the collider. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the collider. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the collider. @@ -79,12 +83,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initCollider({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Inherited from @@ -93,29 +97,33 @@ component.initCollider( #### Defined in -[packages/2d/src/FComponent2d.ts:205](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L205) +[packages/2d/src/FComponent2d.ts:219](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L219) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `PointData` = `...` +• **options?** -The position of the rigid body. +The options for the rigid body. -• **scale**: `PointData` = `...` +• **options.position?**: `PointData` -The scale of the rigid body. +The position of the rigid body. -• **rotation**: `number` = `...` +• **options.rotation?**: `number` The rotation of the rigid body. -• **shape**: [`F2dShapes`](../enumerations/F2dShapes.md) = `F2dShapes.SQUARE` +• **options.scale?**: `PointData` + +The scale of the rigid body. + +• **options.shape?**: [`F2dShapes`](../enumerations/F2dShapes.md) The shape of the rigid body. @@ -130,12 +138,12 @@ Init a rigid body for the model. #### Example ```ts -component.initRigidBody( - new PIXI.Point(0, 0), - new PIXI.Point(1, 1), - 0, - F2dShapes.SQUARE -) +component.initRigidBody({ + position: new PIXI.Point(0, 0), + scale: new PIXI.Point(1, 1), + rotation: 0, + shape: F2dShapes.SQUARE +}) ``` #### Inherited from @@ -144,7 +152,7 @@ component.initRigidBody( #### Defined in -[packages/2d/src/FComponent2d.ts:164](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L164) +[packages/2d/src/FComponent2d.ts:165](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L165) *** @@ -171,7 +179,7 @@ Should be called every frame. #### Defined in -[packages/2d/src/polygons/FSquare.ts:29](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/polygons/FSquare.ts#L29) +[packages/2d/src/polygons/FSquare.ts:29](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/polygons/FSquare.ts#L29) *** @@ -209,7 +217,7 @@ component.setPosition(0, 0) #### Defined in -[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L100) +[packages/2d/src/FComponent2d.ts:100](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L100) *** @@ -243,7 +251,7 @@ component.setRotation(Math.PI / 2) #### Defined in -[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L131) +[packages/2d/src/FComponent2d.ts:131](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L131) *** @@ -277,7 +285,7 @@ component.setRotationDegree(90) #### Defined in -[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L144) +[packages/2d/src/FComponent2d.ts:144](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L144) *** @@ -315,7 +323,7 @@ component.setScale(1, 1) #### Defined in -[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L114) +[packages/2d/src/FComponent2d.ts:114](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L114) ## Properties @@ -331,7 +339,7 @@ RAPIER Collider #### Defined in -[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L46) +[packages/2d/src/FComponent2d.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L46) *** @@ -347,7 +355,7 @@ PIXI container #### Defined in -[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L22) +[packages/2d/src/FComponent2d.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L22) *** @@ -363,7 +371,7 @@ Position of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L28) +[packages/2d/src/FComponent2d.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L28) *** @@ -379,7 +387,7 @@ RAPIER RigidBody #### Defined in -[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L42) +[packages/2d/src/FComponent2d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L42) *** @@ -395,7 +403,7 @@ Rotation of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L36) +[packages/2d/src/FComponent2d.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L36) *** @@ -411,7 +419,7 @@ Scale of the component. #### Defined in -[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L32) +[packages/2d/src/FComponent2d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L32) *** @@ -427,4 +435,4 @@ The scene which the component is in. #### Defined in -[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/FComponent2d.ts#L17) +[packages/2d/src/FComponent2d.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/FComponent2d.ts#L17) diff --git a/docs/api/2d/enumerations/F2dShapes.md b/docs/api/2d/enumerations/F2dShapes.md index 90f5a53a..cc754668 100644 --- a/docs/api/2d/enumerations/F2dShapes.md +++ b/docs/api/2d/enumerations/F2dShapes.md @@ -10,7 +10,7 @@ #### Defined in -[packages/2d/src/types/F2dShapes.ts:4](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/types/F2dShapes.ts#L4) +[packages/2d/src/types/F2dShapes.ts:4](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/types/F2dShapes.ts#L4) *** @@ -20,4 +20,4 @@ #### Defined in -[packages/2d/src/types/F2dShapes.ts:3](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/2d/src/types/F2dShapes.ts#L3) +[packages/2d/src/types/F2dShapes.ts:3](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/2d/src/types/F2dShapes.ts#L3) diff --git a/docs/api/3d/classes/FAttachedCamera.md b/docs/api/3d/classes/FAttachedCamera.md index 8f948a1d..c543769b 100644 --- a/docs/api/3d/classes/FAttachedCamera.md +++ b/docs/api/3d/classes/FAttachedCamera.md @@ -45,7 +45,7 @@ Model that the camera is attached to #### Defined in -[packages/3d/src/cameras/FAttachedCamera.ts:29](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FAttachedCamera.ts#L29) +[packages/3d/src/cameras/FAttachedCamera.ts:29](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FAttachedCamera.ts#L29) ## Methods @@ -1087,7 +1087,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/cameras/FAttachedCamera.ts:34](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FAttachedCamera.ts#L34) +[packages/3d/src/cameras/FAttachedCamera.ts:34](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FAttachedCamera.ts#L34) *** @@ -1468,7 +1468,7 @@ Set the position of the camera. #### Defined in -[packages/3d/src/cameras/FAttachedCamera.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FAttachedCamera.ts#L46) +[packages/3d/src/cameras/FAttachedCamera.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FAttachedCamera.ts#L46) *** @@ -1498,7 +1498,7 @@ Set the rotation of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L32) +[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L32) *** @@ -1640,7 +1640,7 @@ Set the scale of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L25) +[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L25) *** @@ -2140,7 +2140,7 @@ node\_modules/@types/three/src/cameras/PerspectiveCamera.d.ts:64 #### Defined in -[packages/3d/src/cameras/FAttachedCamera.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FAttachedCamera.ts#L22) +[packages/3d/src/cameras/FAttachedCamera.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FAttachedCamera.ts#L22) *** @@ -2727,7 +2727,7 @@ node\_modules/@types/three/src/core/Object3D.d.ts:140 #### Defined in -[packages/3d/src/cameras/FAttachedCamera.ts:24](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FAttachedCamera.ts#L24) +[packages/3d/src/cameras/FAttachedCamera.ts:24](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FAttachedCamera.ts#L24) *** diff --git a/docs/api/3d/classes/FCamera3d.md b/docs/api/3d/classes/FCamera3d.md index bcc653ae..5b59d6c2 100644 --- a/docs/api/3d/classes/FCamera3d.md +++ b/docs/api/3d/classes/FCamera3d.md @@ -36,7 +36,7 @@ The base class for cameras in FibboJS. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:9](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L9) +[packages/3d/src/cameras/FCamera3d.ts:9](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L9) ## Methods @@ -1078,7 +1078,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:13](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L13) +[packages/3d/src/cameras/FCamera3d.ts:13](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L13) *** @@ -1455,7 +1455,7 @@ Set the position of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:18](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L18) +[packages/3d/src/cameras/FCamera3d.ts:18](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L18) *** @@ -1481,7 +1481,7 @@ Set the rotation of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L32) +[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L32) *** @@ -1619,7 +1619,7 @@ Set the scale of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L25) +[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L25) *** diff --git a/docs/api/3d/classes/FComponent3d.md b/docs/api/3d/classes/FComponent3d.md index 3d7ca928..0b0d5b0c 100644 --- a/docs/api/3d/classes/FComponent3d.md +++ b/docs/api/3d/classes/FComponent3d.md @@ -33,29 +33,33 @@ The 3D scene where the component will be added. #### Defined in -[packages/3d/src/FComponent3d.ts:50](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L50) +[packages/3d/src/FComponent3d.ts:50](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L50) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the collider. If not defined, it will use the default position of the FComponent3d. +The options for the collider. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the collider. If not defined, it will use the default scale of the FComponent3d. +The position of the collider. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the collider. If not defined, it will default to F3dShapes.CUBE. @@ -71,39 +75,43 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(1, 1, 1), - new THREE.Vector3(0, 0, 0), - F3dShapes.CUBE -) +component.initCollider({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Defined in -[packages/3d/src/FComponent3d.ts:217](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L217) +[packages/3d/src/FComponent3d.ts:236](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L236) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the rigid body. If not defined, it will use the default position of the FComponent3d. +The options for the rigid body. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. +The position of the rigid body. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. @@ -118,12 +126,17 @@ Init a rigid body for the component. #### Example ```ts -component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) +component.initRigidBody({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Defined in -[packages/3d/src/FComponent3d.ts:173](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L173) +[packages/3d/src/FComponent3d.ts:179](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L179) *** @@ -150,7 +163,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/FComponent3d.ts:59](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L59) +[packages/3d/src/FComponent3d.ts:59](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L59) *** @@ -188,7 +201,7 @@ component.setPosition(0, 1, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L92) +[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L92) *** @@ -226,7 +239,7 @@ component.setRotation(0, Math.PI / 2, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L127) +[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L127) *** @@ -264,7 +277,7 @@ component.setRotationDegree(0, 90, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L147) +[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L147) *** @@ -296,7 +309,7 @@ Set the scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L108) +[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L108) ## Properties @@ -308,7 +321,7 @@ RAPIER Collider #### Defined in -[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L45) +[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L45) *** @@ -320,7 +333,7 @@ Mesh #### Defined in -[packages/3d/src/FComponent3d.ts:21](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L21) +[packages/3d/src/FComponent3d.ts:21](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L21) *** @@ -332,7 +345,7 @@ The position of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L27) +[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L27) *** @@ -344,7 +357,7 @@ RAPIER RigidBody #### Defined in -[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L41) +[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L41) *** @@ -356,7 +369,7 @@ The rotation of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L35) +[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L35) *** @@ -368,7 +381,7 @@ The scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L31) +[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L31) *** @@ -380,4 +393,4 @@ The scene which the component is in. #### Defined in -[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L16) +[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L16) diff --git a/docs/api/3d/classes/FCube.md b/docs/api/3d/classes/FCube.md index 41e2b9ac..f71c4b90 100644 --- a/docs/api/3d/classes/FCube.md +++ b/docs/api/3d/classes/FCube.md @@ -41,29 +41,33 @@ scene.addComponent(cube) #### Defined in -[packages/3d/src/model/FCube.ts:18](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FCube.ts#L18) +[packages/3d/src/model/FCube.ts:18](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FCube.ts#L18) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the collider. If not defined, it will use the default position of the FComponent3d. +The options for the collider. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the collider. If not defined, it will use the default scale of the FComponent3d. +The position of the collider. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the collider. If not defined, it will default to F3dShapes.CUBE. @@ -79,12 +83,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(1, 1, 1), - new THREE.Vector3(0, 0, 0), - F3dShapes.CUBE -) +component.initCollider({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -93,29 +97,33 @@ component.initCollider( #### Defined in -[packages/3d/src/FComponent3d.ts:217](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L217) +[packages/3d/src/FComponent3d.ts:236](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L236) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the rigid body. If not defined, it will use the default position of the FComponent3d. +The options for the rigid body. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. +The position of the rigid body. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. @@ -130,7 +138,12 @@ Init a rigid body for the component. #### Example ```ts -component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) +component.initRigidBody({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -139,7 +152,7 @@ component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), #### Defined in -[packages/3d/src/FComponent3d.ts:173](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L173) +[packages/3d/src/FComponent3d.ts:179](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L179) *** @@ -166,7 +179,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/model/FCube.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FCube.ts#L22) +[packages/3d/src/model/FCube.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FCube.ts#L22) *** @@ -200,7 +213,7 @@ cube.setColor(0xff0000) #### Defined in -[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L37) +[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L37) *** @@ -242,7 +255,7 @@ component.setPosition(0, 1, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L92) +[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L92) *** @@ -284,7 +297,7 @@ component.setRotation(0, Math.PI / 2, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L127) +[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L127) *** @@ -326,7 +339,7 @@ component.setRotationDegree(0, 90, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L147) +[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L147) *** @@ -362,7 +375,7 @@ Set the scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L108) +[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L108) ## Properties @@ -378,7 +391,7 @@ RAPIER Collider #### Defined in -[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L45) +[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L45) *** @@ -395,7 +408,7 @@ directly available after the constructor, as a polyhedron is created synchronous #### Defined in -[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L15) +[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L15) *** @@ -411,7 +424,7 @@ The position of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L27) +[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L27) *** @@ -427,7 +440,7 @@ RAPIER RigidBody #### Defined in -[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L41) +[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L41) *** @@ -443,7 +456,7 @@ The rotation of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L35) +[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L35) *** @@ -459,7 +472,7 @@ The scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L31) +[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L31) *** @@ -475,4 +488,4 @@ The scene which the component is in. #### Defined in -[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L16) +[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L16) diff --git a/docs/api/3d/classes/FFixedCamera.md b/docs/api/3d/classes/FFixedCamera.md index 17e8b0c0..2ee46541 100644 --- a/docs/api/3d/classes/FFixedCamera.md +++ b/docs/api/3d/classes/FFixedCamera.md @@ -38,7 +38,7 @@ scene.camera.lookAt(0, 0, 0) #### Defined in -[packages/3d/src/cameras/FFixedCamera.ts:18](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FFixedCamera.ts#L18) +[packages/3d/src/cameras/FFixedCamera.ts:18](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FFixedCamera.ts#L18) ## Methods @@ -1080,7 +1080,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/cameras/FFixedCamera.ts:22](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FFixedCamera.ts#L22) +[packages/3d/src/cameras/FFixedCamera.ts:22](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FFixedCamera.ts#L22) *** @@ -1461,7 +1461,7 @@ Set the position of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:18](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L18) +[packages/3d/src/cameras/FCamera3d.ts:18](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L18) *** @@ -1491,7 +1491,7 @@ Set the rotation of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L32) +[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L32) *** @@ -1633,7 +1633,7 @@ Set the scale of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L25) +[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L25) *** diff --git a/docs/api/3d/classes/FGLTF.md b/docs/api/3d/classes/FGLTF.md index 716d89a7..a7522c9e 100644 --- a/docs/api/3d/classes/FGLTF.md +++ b/docs/api/3d/classes/FGLTF.md @@ -48,7 +48,7 @@ Should be a GLTF or GLB file. #### Defined in -[packages/3d/src/model/FGLTF.ts:43](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L43) +[packages/3d/src/model/FGLTF.ts:43](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L43) ## Methods @@ -62,29 +62,33 @@ Should be a GLTF or GLB file. #### Defined in -[packages/3d/src/model/FGLTF.ts:98](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L98) +[packages/3d/src/model/FGLTF.ts:98](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L98) *** ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the collider. If not defined, it will use the default position of the FComponent3d. +The options for the collider. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the collider. If not defined, it will use the default scale of the FComponent3d. +The position of the collider. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the collider. If not defined, it will default to F3dShapes.CUBE. @@ -100,12 +104,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(1, 1, 1), - new THREE.Vector3(0, 0, 0), - F3dShapes.CUBE -) +component.initCollider({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -114,29 +118,33 @@ component.initCollider( #### Defined in -[packages/3d/src/FComponent3d.ts:217](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L217) +[packages/3d/src/FComponent3d.ts:236](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L236) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the rigid body. If not defined, it will use the default position of the FComponent3d. +The options for the rigid body. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. +The position of the rigid body. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. @@ -151,7 +159,12 @@ Init a rigid body for the component. #### Example ```ts -component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) +component.initRigidBody({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -160,7 +173,7 @@ component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), #### Defined in -[packages/3d/src/FComponent3d.ts:173](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L173) +[packages/3d/src/FComponent3d.ts:179](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L179) *** @@ -187,7 +200,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/model/FGLTF.ts:90](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L90) +[packages/3d/src/model/FGLTF.ts:90](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L90) *** @@ -205,7 +218,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/model/FGLTF.ts:94](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L94) +[packages/3d/src/model/FGLTF.ts:94](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L94) *** @@ -247,7 +260,7 @@ component.setPosition(0, 1, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L92) +[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L92) *** @@ -289,7 +302,7 @@ component.setRotation(0, Math.PI / 2, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L127) +[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L127) *** @@ -331,7 +344,7 @@ component.setRotationDegree(0, 90, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L147) +[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L147) *** @@ -367,7 +380,7 @@ Set the scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L108) +[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L108) ## Properties @@ -383,7 +396,7 @@ RAPIER Collider #### Defined in -[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L45) +[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L45) *** @@ -399,7 +412,7 @@ Mesh #### Defined in -[packages/3d/src/FComponent3d.ts:21](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L21) +[packages/3d/src/FComponent3d.ts:21](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L21) *** @@ -409,7 +422,7 @@ Mesh #### Defined in -[packages/3d/src/model/FGLTF.ts:36](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L36) +[packages/3d/src/model/FGLTF.ts:36](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L36) *** @@ -425,7 +438,7 @@ The position of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L27) +[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L27) *** @@ -441,7 +454,7 @@ RAPIER RigidBody #### Defined in -[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L41) +[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L41) *** @@ -457,7 +470,7 @@ The rotation of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L35) +[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L35) *** @@ -473,7 +486,7 @@ The scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L31) +[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L31) *** @@ -489,7 +502,7 @@ The scene which the component is in. #### Defined in -[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L16) +[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L16) *** @@ -499,4 +512,4 @@ The scene which the component is in. #### Defined in -[packages/3d/src/model/FGLTF.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FGLTF.ts#L35) +[packages/3d/src/model/FGLTF.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FGLTF.ts#L35) diff --git a/docs/api/3d/classes/FGameCamera.md b/docs/api/3d/classes/FGameCamera.md index 8828d058..30e970f0 100644 --- a/docs/api/3d/classes/FGameCamera.md +++ b/docs/api/3d/classes/FGameCamera.md @@ -49,7 +49,7 @@ Scene that the camera is in #### Defined in -[packages/3d/src/cameras/FGameCamera.ts:29](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FGameCamera.ts#L29) +[packages/3d/src/cameras/FGameCamera.ts:29](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FGameCamera.ts#L29) ## Methods @@ -1091,7 +1091,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/cameras/FGameCamera.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FGameCamera.ts#L35) +[packages/3d/src/cameras/FGameCamera.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FGameCamera.ts#L35) *** @@ -1472,7 +1472,7 @@ Set the position of the camera. #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:47](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L47) +[packages/3d/src/cameras/FOrbitCamera.ts:47](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L47) *** @@ -1502,7 +1502,7 @@ Set the rotation of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L32) +[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L32) *** @@ -1644,7 +1644,7 @@ Set the scale of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L25) +[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L25) *** @@ -2148,7 +2148,7 @@ node\_modules/@types/three/src/cameras/PerspectiveCamera.d.ts:64 #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:23](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L23) +[packages/3d/src/cameras/FOrbitCamera.ts:23](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L23) *** @@ -2206,7 +2206,7 @@ node\_modules/@types/three/src/core/Object3D.d.ts:100 #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L25) +[packages/3d/src/cameras/FOrbitCamera.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L25) *** diff --git a/docs/api/3d/classes/FOrbitCamera.md b/docs/api/3d/classes/FOrbitCamera.md index 995e81c4..aeac9ad1 100644 --- a/docs/api/3d/classes/FOrbitCamera.md +++ b/docs/api/3d/classes/FOrbitCamera.md @@ -53,7 +53,7 @@ Scene that the camera is in #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L31) +[packages/3d/src/cameras/FOrbitCamera.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L31) ## Methods @@ -1095,7 +1095,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:39](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L39) +[packages/3d/src/cameras/FOrbitCamera.ts:39](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L39) *** @@ -1476,7 +1476,7 @@ Set the position of the camera. #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:47](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L47) +[packages/3d/src/cameras/FOrbitCamera.ts:47](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L47) *** @@ -1506,7 +1506,7 @@ Set the rotation of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L32) +[packages/3d/src/cameras/FCamera3d.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L32) *** @@ -1648,7 +1648,7 @@ Set the scale of the camera. #### Defined in -[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FCamera3d.ts#L25) +[packages/3d/src/cameras/FCamera3d.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FCamera3d.ts#L25) *** @@ -2148,7 +2148,7 @@ node\_modules/@types/three/src/cameras/PerspectiveCamera.d.ts:64 #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:23](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L23) +[packages/3d/src/cameras/FOrbitCamera.ts:23](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L23) *** @@ -2202,7 +2202,7 @@ node\_modules/@types/three/src/core/Object3D.d.ts:100 #### Defined in -[packages/3d/src/cameras/FOrbitCamera.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/cameras/FOrbitCamera.ts#L25) +[packages/3d/src/cameras/FOrbitCamera.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/cameras/FOrbitCamera.ts#L25) *** diff --git a/docs/api/3d/classes/FPolyhedron.md b/docs/api/3d/classes/FPolyhedron.md index d214429f..1ea6223c 100644 --- a/docs/api/3d/classes/FPolyhedron.md +++ b/docs/api/3d/classes/FPolyhedron.md @@ -36,29 +36,33 @@ Defaults to a cube. #### Defined in -[packages/3d/src/model/FPolyhedron.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L17) +[packages/3d/src/model/FPolyhedron.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L17) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the collider. If not defined, it will use the default position of the FComponent3d. +The options for the collider. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the collider. If not defined, it will use the default scale of the FComponent3d. +The position of the collider. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the collider. If not defined, it will default to F3dShapes.CUBE. @@ -74,12 +78,12 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(1, 1, 1), - new THREE.Vector3(0, 0, 0), - F3dShapes.CUBE -) +component.initCollider({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -88,29 +92,33 @@ component.initCollider( #### Defined in -[packages/3d/src/FComponent3d.ts:217](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L217) +[packages/3d/src/FComponent3d.ts:236](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L236) *** ### initRigidBody() -> **initRigidBody**(`position`, `scale`, `rotation`, `shape`): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the rigid body. If not defined, it will use the default position of the FComponent3d. +The options for the rigid body. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. +The position of the rigid body. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. @@ -125,7 +133,12 @@ Init a rigid body for the component. #### Example ```ts -component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) +component.initRigidBody({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Inherited from @@ -134,7 +147,7 @@ component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), #### Defined in -[packages/3d/src/FComponent3d.ts:173](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L173) +[packages/3d/src/FComponent3d.ts:179](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L179) *** @@ -161,7 +174,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/model/FPolyhedron.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L25) +[packages/3d/src/model/FPolyhedron.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L25) *** @@ -191,7 +204,7 @@ cube.setColor(0xff0000) #### Defined in -[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L37) +[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L37) *** @@ -233,7 +246,7 @@ component.setPosition(0, 1, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L92) +[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L92) *** @@ -275,7 +288,7 @@ component.setRotation(0, Math.PI / 2, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L127) +[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L127) *** @@ -317,7 +330,7 @@ component.setRotationDegree(0, 90, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L147) +[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L147) *** @@ -353,7 +366,7 @@ Set the scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L108) +[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L108) ## Properties @@ -369,7 +382,7 @@ RAPIER Collider #### Defined in -[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L45) +[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L45) *** @@ -386,7 +399,7 @@ directly available after the constructor, as a polyhedron is created synchronous #### Defined in -[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L15) +[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L15) *** @@ -402,7 +415,7 @@ The position of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L27) +[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L27) *** @@ -418,7 +431,7 @@ RAPIER RigidBody #### Defined in -[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L41) +[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L41) *** @@ -434,7 +447,7 @@ The rotation of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L35) +[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L35) *** @@ -450,7 +463,7 @@ The scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L31) +[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L31) *** @@ -466,4 +479,4 @@ The scene which the component is in. #### Defined in -[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L16) +[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L16) diff --git a/docs/api/3d/classes/FScene3d.md b/docs/api/3d/classes/FScene3d.md index 933dd13d..f9abd05e 100644 --- a/docs/api/3d/classes/FScene3d.md +++ b/docs/api/3d/classes/FScene3d.md @@ -61,7 +61,7 @@ import { FCube, FGameCamera, FScene3d } from '@fibbojs/3d' #### Defined in -[packages/3d/src/FScene3d.ts:55](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L55) +[packages/3d/src/FScene3d.ts:55](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L55) ## Methods @@ -87,7 +87,7 @@ Add a component to the scene. #### Defined in -[packages/3d/src/FScene3d.ts:154](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L154) +[packages/3d/src/FScene3d.ts:154](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L154) *** @@ -101,7 +101,7 @@ Add a component to the scene. #### Defined in -[packages/3d/src/FScene3d.ts:66](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L66) +[packages/3d/src/FScene3d.ts:66](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L66) *** @@ -115,7 +115,7 @@ Add a component to the scene. #### Defined in -[packages/3d/src/FScene3d.ts:122](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L122) +[packages/3d/src/FScene3d.ts:122](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L122) *** @@ -151,7 +151,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:53](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L53) +[packages/3d/src/FScene3d.ts:53](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L53) *** @@ -165,7 +165,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:46](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L46) +[packages/3d/src/FScene3d.ts:46](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L46) *** @@ -179,7 +179,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:42](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L42) +[packages/3d/src/FScene3d.ts:42](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L42) *** @@ -189,7 +189,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:48](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L48) +[packages/3d/src/FScene3d.ts:48](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L48) *** @@ -199,7 +199,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:47](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L47) +[packages/3d/src/FScene3d.ts:47](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L47) *** @@ -225,7 +225,7 @@ packages/core/dist/index.d.ts:78 #### Defined in -[packages/3d/src/FScene3d.ts:50](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L50) +[packages/3d/src/FScene3d.ts:50](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L50) *** @@ -249,7 +249,7 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/3d/src/FScene3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L45) +[packages/3d/src/FScene3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L45) *** @@ -259,7 +259,7 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/3d/src/FScene3d.ts:44](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L44) +[packages/3d/src/FScene3d.ts:44](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L44) *** @@ -273,4 +273,4 @@ packages/core/dist/index.d.ts:69 #### Defined in -[packages/3d/src/FScene3d.ts:51](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FScene3d.ts#L51) +[packages/3d/src/FScene3d.ts:51](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FScene3d.ts#L51) diff --git a/docs/api/3d/classes/FSphere.md b/docs/api/3d/classes/FSphere.md index 5204fe16..cfb84d87 100644 --- a/docs/api/3d/classes/FSphere.md +++ b/docs/api/3d/classes/FSphere.md @@ -41,29 +41,33 @@ scene.addComponent(cube) #### Defined in -[packages/3d/src/model/FSphere.ts:20](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FSphere.ts#L20) +[packages/3d/src/model/FSphere.ts:20](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FSphere.ts#L20) ## Methods ### initCollider() -> **initCollider**(`position`, `scale`, `rotation`, `shape`): `void` +> **initCollider**(`options`?): `void` #### Parameters -• **position**: `Vector3` = `...` +• **options?** -The position of the collider. If not defined, it will use the default position of the FComponent3d. +The options for the collider. -• **scale**: `Vector3` = `...` +• **options.position?**: `Vector3` -The scale of the collider. If not defined, it will use the default scale of the FComponent3d. +The position of the collider. If not defined, it will use the default position of the FComponent3d. -• **rotation**: `Vector3` = `...` +• **options.rotation?**: `Vector3` The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. -• **shape**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.CUBE` +• **options.scale?**: `Vector3` + +The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the collider. If not defined, it will default to F3dShapes.CUBE. @@ -79,43 +83,47 @@ This is useful for static objects. #### Example ```ts -component.initCollider( - new THREE.Vector3(0, 1, 0), - new THREE.Vector3(1, 1, 1), - new THREE.Vector3(0, 0, 0), - F3dShapes.CUBE -) +component.initCollider({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` -#### Inherited from +#### Overrides [`FPolyhedron`](FPolyhedron.md).[`initCollider`](FPolyhedron.md#initcollider) #### Defined in -[packages/3d/src/FComponent3d.ts:217](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L217) +[packages/3d/src/model/FSphere.ts:44](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FSphere.ts#L44) *** ### initRigidBody() -> **initRigidBody**(`position`?, `scale`?, `rotation`?, `shape`?): `void` +> **initRigidBody**(`options`?): `void` #### Parameters -• **position?**: `Vector3` +• **options?** -The position of the rigid body. If not defined, it will use the default position of the FComponent3d. +The options for the rigid body. -• **scale?**: `Vector3` +• **options.position?**: `Vector3` -The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. +The position of the rigid body. If not defined, it will use the default position of the FComponent3d. -• **rotation?**: `Vector3` +• **options.rotation?**: `Vector3` The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. -• **shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) = `F3dShapes.SPHERE` +• **options.scale?**: `Vector3` + +The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + +• **options.shape?**: [`F3dShapes`](../enumerations/F3dShapes.md) The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. @@ -130,7 +138,12 @@ Init a rigid body for the component. #### Example ```ts -component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) +component.initRigidBody({ + position: new THREE.Vector3(0, 1, 0), + scale: new THREE.Vector3(1, 1, 1), + rotation: new THREE.Vector3(0, 0, 0), + shape: F3dShapes.CUBE +}) ``` #### Overrides @@ -139,7 +152,7 @@ component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), #### Defined in -[packages/3d/src/model/FSphere.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FSphere.ts#L32) +[packages/3d/src/model/FSphere.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FSphere.ts#L32) *** @@ -166,7 +179,7 @@ Should be called every frame. #### Defined in -[packages/3d/src/model/FSphere.ts:28](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FSphere.ts#L28) +[packages/3d/src/model/FSphere.ts:28](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FSphere.ts#L28) *** @@ -200,7 +213,7 @@ cube.setColor(0xff0000) #### Defined in -[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L37) +[packages/3d/src/model/FPolyhedron.ts:37](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L37) *** @@ -242,7 +255,7 @@ component.setPosition(0, 1, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L92) +[packages/3d/src/FComponent3d.ts:92](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L92) *** @@ -284,7 +297,7 @@ component.setRotation(0, Math.PI / 2, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L127) +[packages/3d/src/FComponent3d.ts:127](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L127) *** @@ -326,7 +339,7 @@ component.setRotationDegree(0, 90, 0) #### Defined in -[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L147) +[packages/3d/src/FComponent3d.ts:147](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L147) *** @@ -362,7 +375,7 @@ Set the scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L108) +[packages/3d/src/FComponent3d.ts:108](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L108) ## Properties @@ -378,7 +391,7 @@ RAPIER Collider #### Defined in -[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L45) +[packages/3d/src/FComponent3d.ts:45](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L45) *** @@ -395,7 +408,7 @@ directly available after the constructor, as a polyhedron is created synchronous #### Defined in -[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/model/FPolyhedron.ts#L15) +[packages/3d/src/model/FPolyhedron.ts:15](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/model/FPolyhedron.ts#L15) *** @@ -411,7 +424,7 @@ The position of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L27) +[packages/3d/src/FComponent3d.ts:27](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L27) *** @@ -427,7 +440,7 @@ RAPIER RigidBody #### Defined in -[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L41) +[packages/3d/src/FComponent3d.ts:41](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L41) *** @@ -443,7 +456,7 @@ The rotation of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L35) +[packages/3d/src/FComponent3d.ts:35](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L35) *** @@ -459,7 +472,7 @@ The scale of the component. #### Defined in -[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L31) +[packages/3d/src/FComponent3d.ts:31](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L31) *** @@ -475,4 +488,4 @@ The scene which the component is in. #### Defined in -[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/FComponent3d.ts#L16) +[packages/3d/src/FComponent3d.ts:16](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/FComponent3d.ts#L16) diff --git a/docs/api/3d/enumerations/F3dShapes.md b/docs/api/3d/enumerations/F3dShapes.md index bab4908f..f73e6406 100644 --- a/docs/api/3d/enumerations/F3dShapes.md +++ b/docs/api/3d/enumerations/F3dShapes.md @@ -10,7 +10,7 @@ #### Defined in -[packages/3d/src/types/F3dShapes.ts:3](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/types/F3dShapes.ts#L3) +[packages/3d/src/types/F3dShapes.ts:3](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/types/F3dShapes.ts#L3) *** @@ -20,4 +20,4 @@ #### Defined in -[packages/3d/src/types/F3dShapes.ts:4](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/3d/src/types/F3dShapes.ts#L4) +[packages/3d/src/types/F3dShapes.ts:4](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/3d/src/types/F3dShapes.ts#L4) diff --git a/docs/api/core/classes/FCamera.md b/docs/api/core/classes/FCamera.md index 011d5f9c..7c3b3ba0 100644 --- a/docs/api/core/classes/FCamera.md +++ b/docs/api/core/classes/FCamera.md @@ -26,7 +26,7 @@ The base class for cameras in FibboJS. #### Defined in -[packages/core/src/FCamera.ts:7](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FCamera.ts#L7) +[packages/core/src/FCamera.ts:7](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FCamera.ts#L7) ## Methods @@ -55,4 +55,4 @@ Should be called every frame. #### Defined in -[packages/core/src/FComponent.ts:13](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FComponent.ts#L13) +[packages/core/src/FComponent.ts:13](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FComponent.ts#L13) diff --git a/docs/api/core/classes/FComponent.md b/docs/api/core/classes/FComponent.md index c8891bd5..d94a60fc 100644 --- a/docs/api/core/classes/FComponent.md +++ b/docs/api/core/classes/FComponent.md @@ -22,7 +22,7 @@ The base class for all 2D and 3D components in FibboJS. #### Defined in -[packages/core/src/FComponent.ts:5](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FComponent.ts#L5) +[packages/core/src/FComponent.ts:5](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FComponent.ts#L5) ## Methods @@ -47,4 +47,4 @@ Should be called every frame. #### Defined in -[packages/core/src/FComponent.ts:13](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FComponent.ts#L13) +[packages/core/src/FComponent.ts:13](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FComponent.ts#L13) diff --git a/docs/api/core/classes/FGroup.md b/docs/api/core/classes/FGroup.md index 1c5e35cf..6f512059 100644 --- a/docs/api/core/classes/FGroup.md +++ b/docs/api/core/classes/FGroup.md @@ -33,7 +33,7 @@ If no components are provided, the group will be empty. #### Defined in -[packages/core/src/FGroup.ts:18](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FGroup.ts#L18) +[packages/core/src/FGroup.ts:18](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FGroup.ts#L18) ## Methods @@ -55,7 +55,7 @@ Add a component to the group. #### Defined in -[packages/core/src/FGroup.ts:25](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FGroup.ts#L25) +[packages/core/src/FGroup.ts:25](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FGroup.ts#L25) *** @@ -79,7 +79,7 @@ Update all components in the group. #### Defined in -[packages/core/src/FGroup.ts:40](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FGroup.ts#L40) +[packages/core/src/FGroup.ts:40](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FGroup.ts#L40) *** @@ -101,7 +101,7 @@ Remove a component from the group. #### Defined in -[packages/core/src/FGroup.ts:32](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FGroup.ts#L32) +[packages/core/src/FGroup.ts:32](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FGroup.ts#L32) ## Properties @@ -115,4 +115,4 @@ The components in the group. #### Defined in -[packages/core/src/FGroup.ts:10](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FGroup.ts#L10) +[packages/core/src/FGroup.ts:10](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FGroup.ts#L10) diff --git a/docs/api/core/classes/FScene.md b/docs/api/core/classes/FScene.md index a778421b..63fd7daf 100644 --- a/docs/api/core/classes/FScene.md +++ b/docs/api/core/classes/FScene.md @@ -19,7 +19,7 @@ Also contains the Rapier world if physics is enabled. #### Defined in -[packages/core/src/FScene.ts:19](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L19) +[packages/core/src/FScene.ts:19](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L19) ## Methods @@ -41,7 +41,7 @@ Add a component to the scene. #### Defined in -[packages/core/src/FScene.ts:48](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L48) +[packages/core/src/FScene.ts:48](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L48) *** @@ -63,7 +63,7 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:53](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L53) +[packages/core/src/FScene.ts:53](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L53) ## Properties @@ -73,7 +73,7 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:12](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L12) +[packages/core/src/FScene.ts:12](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L12) *** @@ -83,7 +83,7 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:11](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L11) +[packages/core/src/FScene.ts:11](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L11) *** @@ -105,7 +105,7 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:14](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L14) +[packages/core/src/FScene.ts:14](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L14) *** @@ -115,7 +115,7 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:17](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L17) +[packages/core/src/FScene.ts:17](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L17) *** @@ -125,4 +125,4 @@ Add a callback to the onFrame event. #### Defined in -[packages/core/src/FScene.ts:15](https://github.com/fibbojs/fibbo/blob/2fc7696bf6e72ce4d25b27bb8d1ec5dce7632448/packages/core/src/FScene.ts#L15) +[packages/core/src/FScene.ts:15](https://github.com/fibbojs/fibbo/blob/854b295adc4e4ce7db9ffee939bdf1bce33bc12e/packages/core/src/FScene.ts#L15) diff --git a/packages/2d/src/FComponent2d.ts b/packages/2d/src/FComponent2d.ts index 925e8842..c7bd5e2d 100644 --- a/packages/2d/src/FComponent2d.ts +++ b/packages/2d/src/FComponent2d.ts @@ -147,77 +147,103 @@ export abstract class FComponent2d extends FComponent { /** * @description Init a rigid body for the model. - * @param position The position of the rigid body. - * @param scale The scale of the rigid body. - * @param rotation The rotation of the rigid body. - * @param shape The shape of the rigid body. + * @param options The options for the rigid body. + * @param options.position The position of the rigid body. + * @param options.scale The scale of the rigid body. + * @param options.rotation The rotation of the rigid body. + * @param options.shape The shape of the rigid body. * @example * ```ts - * component.initRigidBody( - * new PIXI.Point(0, 0), - * new PIXI.Point(1, 1), - * 0, - * F2dShapes.SQUARE - * ) + * component.initRigidBody({ + * position: new PIXI.Point(0, 0), + * scale: new PIXI.Point(1, 1), + * rotation: 0, + * shape: F2dShapes.SQUARE + * }) * ``` */ - initRigidBody( - position: PIXI.PointData = new PIXI.Point(this.position.x, this.position.y), - scale: PIXI.PointData = new PIXI.Point(this.scale.x / 2, this.scale.y / 2), - rotation: number = this.rotation, - shape: F2dShapes = F2dShapes.SQUARE, - ): void { + initRigidBody(options?: { + position?: PIXI.PointData + scale?: PIXI.PointData + rotation?: number + shape?: F2dShapes + }): void { + // Apply default options + const DEFAULT_OPTIONS = { + position: new PIXI.Point(this.position.x, this.position.y), + scale: new PIXI.Point(this.scale.x / 2, this.scale.y / 2), + rotation: this.rotation, + shape: F2dShapes.SQUARE, + } + options = { ...DEFAULT_OPTIONS, ...options } + // Validate options + if (!options.position || !options.scale || options.rotation === undefined || !options.shape) + throw new Error('initRigidBody requires position, scale, rotation and shape options') + // Check if the world exists if (!this.scene.world) throw new Error('FScene must have a world to create a rigid body') // Create a dynamic rigid-body. const rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic() - .setTranslation(position.x, position.y) - .setRotation(rotation) + .setTranslation(options.position.x, options.position.y) + .setRotation(options.rotation) this.rigidBody = this.scene.world.createRigidBody(rigidBodyDesc) // Create a collider for the rigid body - const colliderDesc = shape === F2dShapes.SQUARE - ? RAPIER.ColliderDesc.cuboid(scale.x, scale.y) - : RAPIER.ColliderDesc.ball(scale.x) + const colliderDesc = options.shape === F2dShapes.SQUARE + ? RAPIER.ColliderDesc.cuboid(options.scale.x, options.scale.y) + : RAPIER.ColliderDesc.ball(options.scale.x) this.collider = this.scene.world.createCollider(colliderDesc, this.rigidBody) } /** * @description Only init a collider for the component, without a rigid body. * This is useful for static objects. - * @param position The position of the collider. - * @param scale The scale of the collider. - * @param rotation The rotation of the collider. - * @param shape The shape of the collider. + * @param options The options for the collider. + * @param options.position The position of the collider. + * @param options.scale The scale of the collider. + * @param options.rotation The rotation of the collider. + * @param options.shape The shape of the collider. * @example * ```ts - * component.initCollider( - * new PIXI.Point(0, 0), - * new PIXI.Point(1, 1), - * 0, - * F2dShapes.SQUARE - * ) + * component.initCollider({ + * position: new PIXI.Point(0, 0), + * scale: new PIXI.Point(1, 1), + * rotation: 0, + * shape: F2dShapes.SQUARE + * }) * ``` */ - initCollider( - position: PIXI.PointData = new PIXI.Point(this.position.x, this.position.y), - scale: PIXI.PointData = new PIXI.Point(this.scale.x / 2, this.scale.y / 2), - rotation: number = this.rotation, - shape: F2dShapes = F2dShapes.SQUARE, - ): void { + initCollider(options?: { + position?: PIXI.PointData + scale?: PIXI.PointData + rotation?: number + shape?: F2dShapes + }): void { + // Apply default options + const DEFAULT_OPTIONS = { + position: new PIXI.Point(this.position.x, this.position.y), + scale: new PIXI.Point(this.scale.x / 2, this.scale.y / 2), + rotation: this.rotation, + shape: F2dShapes.SQUARE, + } + options = { ...DEFAULT_OPTIONS, ...options } + // Validate options + if (!options.position || !options.scale || options.rotation === undefined || !options.shape) + throw new Error('initCollider requires position, scale, rotation and shape options') + // Check if the world exists if (!this.scene.world) throw new Error('FScene must have a world to create a collider') // Create the collider - const colliderDesc = shape === F2dShapes.SQUARE - ? RAPIER.ColliderDesc.cuboid(scale.x, scale.y) - : RAPIER.ColliderDesc.ball(scale.x) - colliderDesc.setTranslation(position.x, position.y) - colliderDesc.setRotation(rotation) + const colliderDesc = options.shape === F2dShapes.SQUARE + ? RAPIER.ColliderDesc.cuboid(options.scale.x, options.scale.y) + : RAPIER.ColliderDesc.ball(options.scale.x) + colliderDesc.setTranslation(options.position.x, options.position.y) + colliderDesc.setRotation(options.rotation) this.collider = this.scene.world.createCollider(colliderDesc) } } diff --git a/packages/2d/src/FScene2d.ts b/packages/2d/src/FScene2d.ts index 40fb29c4..cbddddc3 100644 --- a/packages/2d/src/FScene2d.ts +++ b/packages/2d/src/FScene2d.ts @@ -148,13 +148,6 @@ export class FScene2d extends FScene { // Initialize Rapier world this.world = new RAPIER.World(this.gravity) - // Create the ground - const ground = new FSquare(this) - ground.setPosition(0, 0) - ground.setScale(10, 0.1) - ground.initCollider() - this.addComponent(ground) - // onFrame this.onFrame((delta) => { // Physics diff --git a/packages/2d/src/polygons/FCircle.ts b/packages/2d/src/polygons/FCircle.ts index bcf6ba98..cf1b7f82 100644 --- a/packages/2d/src/polygons/FCircle.ts +++ b/packages/2d/src/polygons/FCircle.ts @@ -29,21 +29,27 @@ export class FCircle extends FComponent2d { super.onFrame(delta) } - initRigidBody( - position?: PIXI.PointData, - scale?: PIXI.PointData, - rotation?: number, - shape: F2dShapes = F2dShapes.CIRCLE, - ): void { - super.initRigidBody(position, scale, rotation, shape) + initRigidBody(options?: { + position?: PIXI.PointData + scale?: PIXI.PointData + rotation?: number + shape?: F2dShapes + }): void { + super.initRigidBody({ + ...options, + shape: F2dShapes.CIRCLE, + }) } - initCollider( - position?: PIXI.PointData, - scale?: PIXI.PointData, - rotation?: number, - shape: F2dShapes = F2dShapes.CIRCLE, - ): void { - super.initCollider(position, scale, rotation, shape) + initCollider(options?: { + position?: PIXI.PointData + scale?: PIXI.PointData + rotation?: number + shape?: F2dShapes + }): void { + super.initCollider({ + ...options, + shape: F2dShapes.CIRCLE, + }) } } diff --git a/packages/3d/src/FComponent3d.ts b/packages/3d/src/FComponent3d.ts index 8d9cc8d5..a5e922d9 100644 --- a/packages/3d/src/FComponent3d.ts +++ b/packages/3d/src/FComponent3d.ts @@ -161,77 +161,108 @@ export abstract class FComponent3d implements FComponent { /** * @description Init a rigid body for the component. - * @param position The position of the rigid body. If not defined, it will use the default position of the FComponent3d. - * @param scale The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. - * @param rotation The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. - * @param shape The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. + * @param options The options for the rigid body. + * @param options.position The position of the rigid body. If not defined, it will use the default position of the FComponent3d. + * @param options.scale The scale of the rigid body. If not defined, it will use the default scale of the FComponent3d. + * @param options.rotation The rotation of the rigid body. If not defined, it will use the default rotation of the FComponent3d. + * @param options.shape The shape of the rigid body. If not defined, it will default to F3dShapes.CUBE. * @example * ```ts - * component.initRigidBody(new THREE.Vector3(0, 1, 0), new THREE.Vector3(1, 1, 1), new THREE.Vector3(0, 0, 0), F3dShapes.CUBE) + * component.initRigidBody({ + * position: new THREE.Vector3(0, 1, 0), + * scale: new THREE.Vector3(1, 1, 1), + * rotation: new THREE.Vector3(0, 0, 0), + * shape: F3dShapes.CUBE + * }) * ``` */ - initRigidBody( - position: THREE.Vector3 = new THREE.Vector3(this.position.x, this.position.y, this.position.z), - scale: THREE.Vector3 = new THREE.Vector3(this.scale.x / 2, this.scale.y / 2, this.scale.z / 2), - rotation: THREE.Vector3 = new THREE.Vector3(this.rotation.x, this.rotation.y, this.rotation.z), - shape: F3dShapes = F3dShapes.CUBE, - ): void { + initRigidBody(options?: { + position?: THREE.Vector3 + scale?: THREE.Vector3 + rotation?: THREE.Vector3 + shape?: F3dShapes + }): void { + // Apply default options + const DEFAULT_OPTIONS = { + position: new THREE.Vector3(this.position.x, this.position.y, this.position.z), + scale: new THREE.Vector3(this.scale.x / 2, this.scale.y / 2, this.scale.z / 2), + rotation: new THREE.Vector3(this.rotation.x, this.rotation.y, this.rotation.z), + shape: F3dShapes.CUBE, + } + options = { ...DEFAULT_OPTIONS, ...options } + // Validate options + if (!options.position || !options.scale || !options.rotation || !options.shape) + throw new Error('initRigidBody requires position, scale, rotation and shape options') + // Check if the world exists if (!this.scene.world) throw new Error('FScene must have a world to create a rigid body') // Create a dynamic rigid-body. const rigidBodyDesc = RAPIER.RigidBodyDesc.dynamic() - .setTranslation(position.x, position.y, position.z) + .setTranslation(options.position.x, options.position.y, options.position.z) .setRotation( // Create quaternion from Euler angles - new THREE.Quaternion().setFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z)), + new THREE.Quaternion().setFromEuler(new THREE.Euler(options.rotation.x, options.rotation.y, options.rotation.z)), ) this.rigidBody = this.scene.world.createRigidBody(rigidBodyDesc) // Create a cuboid collider attached to the dynamic rigidBody. - const colliderDesc = shape === F3dShapes.CUBE - ? RAPIER.ColliderDesc.cuboid(scale.x, scale.y, scale.z) - : RAPIER.ColliderDesc.ball(scale.x) + const colliderDesc = options.shape === F3dShapes.CUBE + ? RAPIER.ColliderDesc.cuboid(options.scale.x, options.scale.y, options.scale.z) + : RAPIER.ColliderDesc.ball(options.scale.x) this.collider = this.scene.world.createCollider(colliderDesc, this.rigidBody) } /** * @description Only init a collider for the component, without a rigid body. * This is useful for static objects. - * @param position The position of the collider. If not defined, it will use the default position of the FComponent3d. - * @param scale The scale of the collider. If not defined, it will use the default scale of the FComponent3d. - * @param rotation The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. - * @param shape The shape of the collider. If not defined, it will default to F3dShapes.CUBE. + * @param options The options for the collider. + * @param options.position The position of the collider. If not defined, it will use the default position of the FComponent3d. + * @param options.scale The scale of the collider. If not defined, it will use the default scale of the FComponent3d. + * @param options.rotation The rotation of the collider. If not defined, it will use the default rotation of the FComponent3d. + * @param options.shape The shape of the collider. If not defined, it will default to F3dShapes.CUBE. * @example * ```ts - * component.initCollider( - * new THREE.Vector3(0, 1, 0), - * new THREE.Vector3(1, 1, 1), - * new THREE.Vector3(0, 0, 0), - * F3dShapes.CUBE - * ) + * component.initCollider({ + * position: new THREE.Vector3(0, 1, 0), + * scale: new THREE.Vector3(1, 1, 1), + * rotation: new THREE.Vector3(0, 0, 0), + * shape: F3dShapes.CUBE + * }) * ``` */ - initCollider( - position: THREE.Vector3 = new THREE.Vector3(this.position.x, this.position.y, this.position.z), - scale: THREE.Vector3 = new THREE.Vector3(this.scale.x / 2, this.scale.y / 2, this.scale.z / 2), - rotation: THREE.Vector3 = new THREE.Vector3(this.rotation.x, this.rotation.y, this.rotation.z), - shape: F3dShapes = F3dShapes.CUBE, - ): void { + initCollider(options?: { + position?: THREE.Vector3 + scale?: THREE.Vector3 + rotation?: THREE.Vector3 + shape: F3dShapes + }): void { + // Apply default options + const DEFAULT_OPTIONS = { + position: new THREE.Vector3(this.position.x, this.position.y, this.position.z), + scale: new THREE.Vector3(this.scale.x / 2, this.scale.y / 2, this.scale.z / 2), + rotation: new THREE.Vector3(this.rotation.x, this.rotation.y, this.rotation.z), + shape: F3dShapes.CUBE, + } + options = { ...DEFAULT_OPTIONS, ...options } + // Validate options + if (!options.position || !options.scale || !options.rotation || !options.shape) + throw new Error('initCollider requires position, scale, rotation and shape options') + // Check if the world exists if (!this.scene.world) throw new Error('FScene must have a world to create a rigid body') // Create a cuboid collider attached to the dynamic rigidBody. - const colliderDesc = shape === F3dShapes.CUBE - ? RAPIER.ColliderDesc.cuboid(scale.x, scale.y, scale.z) - : RAPIER.ColliderDesc.ball(scale.x) - colliderDesc.setTranslation(position.x, position.y, position.z) + const colliderDesc = options.shape === F3dShapes.CUBE + ? RAPIER.ColliderDesc.cuboid(options.scale.x, options.scale.y, options.scale.z) + : RAPIER.ColliderDesc.ball(options.scale.x) + colliderDesc.setTranslation(options.position.x, options.position.y, options.position.z) colliderDesc.setRotation( // Create quaternion from Euler angles - new THREE.Quaternion().setFromEuler(new THREE.Euler(rotation.x, rotation.y, rotation.z)), + new THREE.Quaternion().setFromEuler(new THREE.Euler(options.rotation.x, options.rotation.y, options.rotation.z)), ) this.collider = this.scene.world.createCollider(colliderDesc) } diff --git a/packages/3d/src/model/FSphere.ts b/packages/3d/src/model/FSphere.ts index 4f2189e4..b1089f0d 100644 --- a/packages/3d/src/model/FSphere.ts +++ b/packages/3d/src/model/FSphere.ts @@ -29,12 +29,27 @@ export class FSphere extends FPolyhedron { super.onFrame(_delta) } - initRigidBody( - position?: THREE.Vector3, - scale?: THREE.Vector3, - rotation?: THREE.Vector3, - shape: F3dShapes = F3dShapes.SPHERE, - ): void { - super.initRigidBody(position, scale, rotation, shape) + initRigidBody(options?: { + position?: THREE.Vector3 + scale?: THREE.Vector3 + rotation?: THREE.Vector3 + shape?: F3dShapes + }): void { + super.initRigidBody({ + ...options, + shape: F3dShapes.SPHERE, + }) + } + + initCollider(options?: { + position?: THREE.Vector3 + scale?: THREE.Vector3 + rotation?: THREE.Vector3 + shape?: F3dShapes + }): void { + super.initCollider({ + ...options, + shape: F3dShapes.SPHERE, + }) } }