Skip to content

Commit f2e4b78

Browse files
committed
feat(general): add physics + improve build
1 parent 3dc31a7 commit f2e4b78

File tree

18 files changed

+2759
-1167
lines changed

18 files changed

+2759
-1167
lines changed

package-lock.json

Lines changed: 759 additions & 767 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
"tsc-files": "^1.1.4",
3838
"typescript": "^5.4.5"
3939
},
40+
"overrides": {
41+
"react-native": "0.76.5"
42+
},
4043
"engines": {
4144
"node": "^22.11.0",
4245
"npm": "^10.9.0"

packages/common/index.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -151,24 +151,25 @@ export enum BabylonPackages {
151151
// specific properties of a single component
152152
export const AdditionalProps: Record<string, string> = {
153153
webXRCamera: ` & WebXRCameraProps`,
154+
mesh: ` & MeshProps`,
154155
};
155156

156157
// specific properties for a category of components
157-
export function getAdditionalProps(jsxElementName: string, Class: any){
158-
if (jsxElementName in AdditionalProps){
158+
export function getAdditionalProps(jsxElementName: string, Class: any) {
159+
if (jsxElementName in AdditionalProps) {
159160
return AdditionalProps[jsxElementName];
160161
}
161162
//@ts-ignore - build phase - Property 'Material' does not exist on type 'typeof import("... node_modules/@babylonjs/core/index", { with: { "resolution-mode": "import" } })'.
162-
if (Class.prototype instanceof BabylonCore.Material){
163+
if (Class.prototype instanceof BabylonCore.Material) {
163164
return ` & MaterialProps`;
164165
}
165166
//@ts-ignore - build phase - Property 'BaseTexture' does not exist on type 'typeof import("... node_modules/@babylonjs/core/index", { with: { "resolution-mode": "import" } })'.
166-
if (Class.prototype instanceof BabylonCore.BaseTexture){
167+
if (Class.prototype instanceof BabylonCore.BaseTexture) {
167168
return ` & TextureProps`;
168169
}
169170
//@ts-ignore - build phase - Property 'Camera' does not exist on type 'typeof import("... node_modules/@babylonjs/core/index", { with: { "resolution-mode": "import" } })'.
170-
if (Class.prototype instanceof BabylonCore.Camera){
171+
if (Class.prototype instanceof BabylonCore.Camera) {
171172
return ` & CameraProps`;
172173
}
173174
return '';
174-
}
175+
}

packages/library/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"peerDependencies": {
3636
"@babylonjs/core": "^7.40.2 ",
3737
"@babylonjs/gui": "^7.40.2 ",
38-
"@babylonjs/havok": "^1.3.7",
3938
"@babylonjs/react-native": "^1.8.6",
4039
"@types/react": "^18.2.0",
4140
"@types/react-dom": "^18.3.1",

packages/library/src/_generated/babylon.core.constructors.ts

Lines changed: 188 additions & 41 deletions
Large diffs are not rendered by default.

packages/library/src/_generated/babylon.core.declarations.ts

Lines changed: 1703 additions & 288 deletions
Large diffs are not rendered by default.

packages/library/src/components/hosts/CameraHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export class CameraHost {
1818
(webXRCamera as ComponentInstance<any>)[key] = value;
1919
});
2020

21-
// use metadata to store children in reconciler
21+
// use metadata to store children in renderer
2222
if (!webXRCamera.metadata) {
2323
webXRCamera.metadata = {
2424
babylonPackage: BabylonPackages.CORE,

packages/library/src/components/hosts/GuiHost.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class GuiHost {
8181
}
8282
});
8383

84-
// use metadata to store children in reconciler
84+
// use metadata to store children in renderer
8585
if (!element.metadata) {
8686
element.metadata = {
8787
babylonPackage: BabylonPackages.GUI,

packages/library/src/components/hosts/Host.test.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,21 @@ describe('Hosts tests', () => {
7777
expect(material).toBeNull();
7878
});
7979

80+
test('should dispose the parent and his children', async () => {
81+
const boxName = 'box';
82+
const boxChildrenName = `${boxName}-children`;
83+
const { scene, unmount } = render(
84+
<box name={boxName}>
85+
<box name={boxChildrenName} />
86+
</box>,
87+
);
88+
unmount();
89+
const box = scene.getMeshById(boxName) as Mesh;
90+
const boxChildren = scene.getMeshById(boxChildrenName) as Mesh;
91+
expect(box).toBeNull();
92+
expect(boxChildren).toBeNull();
93+
});
94+
8095
test('should invoke onCreate when the box has been created', async () => {
8196
const handleCreate = jest.fn();
8297
const boxName = 'box';

packages/library/src/components/hosts/Host.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import '../../index';
77
import coreConstructors from '../../_generated/babylon.core.constructors';
88
import { CoreHostProps } from '@props';
99

10-
const excludedProps = ['children', 'onCreate', 'assignTo', 'cloneFrom', 'instanceFrom', 'propertiesFrom', 'physicsAggregate'];
10+
const excludedProps = ['children', 'onCreate', 'assignTo', 'cloneFrom', 'instanceFrom', 'propertiesFrom'];
1111

1212
export class Host {
1313
static createInstance(type: string, isBuilder: boolean, Class: any, props: CoreHostProps, rootContainer: RootContainer, cloneFn?: Function) {
@@ -48,7 +48,7 @@ export class Host {
4848
});
4949
}
5050

51-
// use metadata to store children in reconciler
51+
// use metadata to store children in renderer
5252
if (!element.metadata) {
5353
element.metadata = {
5454
babylonPackage: BabylonPackages.CORE,

0 commit comments

Comments
 (0)