Skip to content

Commit 4e63a7f

Browse files
committed
feat(general): add WebGPU support
1 parent 459d733 commit 4e63a7f

File tree

11 files changed

+139
-113
lines changed

11 files changed

+139
-113
lines changed

package-lock.json

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

packages/library/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
"dependencies": {
3232
"acorn": "^8.11.3",
3333
"its-fine": "^1.2.5",
34-
"lodash": "^4.17.21",
34+
"lodash-es": "^4.17.21",
3535
"suspend-react": "^0.1.3",
3636
"zustand": "^5.0.3"
3737
},
@@ -61,7 +61,7 @@
6161
"@testing-library/react": "^16.0.1",
6262
"@types/acorn": "^6.0.0",
6363
"@types/jest": "^29.5.14",
64-
"@types/lodash": "^4.17.13",
64+
"@types/lodash-es": "^4.17.12",
6565
"@types/react": "^19",
6666
"@types/react-dom": "^19",
6767
"@types/react-reconciler": "0.31.0",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ const ConstructorsMap: Record<string, Array<string>> = {
791791
lightBlock: ["name"],
792792
lightGizmo: ["gizmoLayer"],
793793
lightInformationBlock: ["name"],
794+
lightingVolume: ["name","scene","shadowGenerator","tesselation"],
794795
lineEdgesRenderer: ["source","epsilon","checkVerticesInsteadOfIndices"],
795796
linesMesh: ["name","scene","parent","source","doNotCloneChildren","useVertexColor","useVertexAlpha","material"],
796797
loadAssetContainerAsync: ["source","scene","options"],

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -794,6 +794,7 @@ import type { Light } from '@babylonjs/core';
794794
import type { LightBlock } from '@babylonjs/core';
795795
import type { LightGizmo } from '@babylonjs/core';
796796
import type { LightInformationBlock } from '@babylonjs/core';
797+
import type { LightingVolume } from '@babylonjs/core';
797798
import type { LineEdgesRenderer } from '@babylonjs/core';
798799
import type { LinesMesh } from '@babylonjs/core';
799800
import type { LoadAssetContainerAsync } from '@babylonjs/core';
@@ -5655,6 +5656,13 @@ gizmoLayer: ConstructorParameters<typeof LightGizmo>[0];
56555656
name: ConstructorParameters<typeof LightInformationBlock>[0];
56565657

56575658
},LightInformationBlock>, any>;
5659+
lightingVolume: React.DetailedHTMLProps<BabylonProps<ExcludeReadonlyAndPrivate<LightingVolume>, {
5660+
name: ConstructorParameters<typeof LightingVolume>[0];
5661+
scene: ConstructorParameters<typeof LightingVolume>[1];
5662+
shadowGenerator: ConstructorParameters<typeof LightingVolume>[2];
5663+
tesselation: ConstructorParameters<typeof LightingVolume>[3];
5664+
5665+
},LightingVolume>, any>;
56585666
lineEdgesRenderer: React.DetailedHTMLProps<BabylonProps<ExcludeReadonlyAndPrivate<LineEdgesRenderer>, {
56595667
source: ConstructorParameters<typeof LineEdgesRenderer>[0];
56605668
epsilon: ConstructorParameters<typeof LineEdgesRenderer>[1];

packages/library/src/core/store.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
import { createStore, type StoreApi, useStore } from 'zustand';
2-
import type { Nullable, Engine, HavokPlugin, Scene, WebXRDefaultExperience } from '@babylonjs/core';
2+
import type { Nullable, Engine as WebGLEngine, WebGPUEngine, HavokPlugin, Scene, WebXRDefaultExperience } from '@babylonjs/core';
33
import { createContext, useContext } from 'react';
44
import type { IPhysicsEngine } from '@babylonjs/core/Physics/IPhysicsEngine';
55

6+
export type Engine = WebGLEngine | WebGPUEngine;
7+
68
export type EngineStore = {
79
engine: Nullable<Engine>;
810
isMultipleCanvas: boolean;

packages/library/src/core/useModel.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { suspend, clear } from 'suspend-react';
33
import type { ISceneLoaderAsyncResult, ImportMeshOptions } from '@babylonjs/core';
44
import { ImportMeshAsync } from '@babylonjs/core/Loading/sceneLoader.js';
55
import { useScene } from './store';
6-
import isEqual from 'lodash/isEqual';
6+
import { isEqual } from 'lodash-es';
77

88
function dispose(model: ISceneLoaderAsyncResult) {
99
Object.values(model).forEach(attribute => {

packages/library/src/reconciler.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { version } from 'react';
22
import ReactReconciler, { type FiberRoot } from 'react-reconciler';
33
import { DefaultEventPriority, NoEventPriority } from 'react-reconciler/constants';
44
import type { AbstractMesh } from '@babylonjs/core';
5-
import lodash from 'lodash';
5+
import { isEqualWith } from 'lodash-es';
66
import { Logger, BabylonPackages, isInstanceOf, builders, CollidingComponents } from '@dvmstudios/reactylon-common';
77
import type { UpdatePayload, RootContainer, EngineContext, Instance, BabylonEntity } from '@types';
88
import { Host, MaterialHost, TextureHost, MeshHost, AdvancedDynamicTextureHost, GuiHost, LightHost, CameraHost, GridHost /*, TransformNodeHost*/ } from './components/hosts';
@@ -18,8 +18,6 @@ const IS_REACT_19 = version.startsWith('19');
1818
type CommitUpdateV19 = [Instance, string, CoreHostProps | GuiHostProps, CoreHostProps | GuiHostProps, any];
1919
type EventPriority = any;
2020

21-
const { isEqualWith } = lodash;
22-
2321
function isParentNeeded(child: BabylonEntity) {
2422
if (isInstanceOf(child, 'Material')) {
2523
return false;

packages/library/src/types/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/* PROPS USED BY JSX ELEMENTS GENERATOR */
22

3-
import type { Engine, Node, Nullable, Scene, WebXRDefaultExperience } from '@babylonjs/core';
3+
import type { Engine as WebGLEngine, WebGPUEngine, Node, Nullable, Scene, WebXRDefaultExperience } from '@babylonjs/core';
44
import { BabylonPackages } from '@dvmstudios/reactylon-common';
55
import type { CommonProps } from './props';
66
import type { EngineStore } from '../core/store';
@@ -79,7 +79,7 @@ export type UpdatePayload = {
7979
};
8080

8181
export type RootContainer = {
82-
engine: Engine;
82+
engine: WebGLEngine | WebGPUEngine;
8383
scene: Scene;
8484
canvas: HTMLCanvasElement | WebGLRenderingContext;
8585
isMultipleCanvas: boolean;

packages/library/src/utils/ObjectUtils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import type { Vector3, Vector4 } from '@babylonjs/core';
22
import { isInstanceOf } from '@dvmstudios/reactylon-common';
3-
import lodash from 'lodash';
4-
5-
const { get, setWith } = lodash;
3+
import { get, setWith } from 'lodash-es';
64

75
export default class ObjectUtils {
86
static set(object: any, path: string, value: any, customizer: any = Object) {

packages/library/src/utils/TestUtils.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ type WrapperProps = React.PropsWithChildren<{
1313

1414
const Wrapper: React.FC<WrapperProps> = ({ children, context }) => {
1515
return (
16-
<Engine antialias _nullEngine={new NullEngine()}>
16+
<Engine _nullEngine={new NullEngine()}>
1717
<Scene
1818
onSceneReady={scene => {
1919
scene.createDefaultCameraOrLight(true, undefined);

0 commit comments

Comments
 (0)