Skip to content

Commit

Permalink
compat: Match AbstractEngine on observable and useEngine hook (scene.…
Browse files Browse the repository at this point in the history
…getEngine())
  • Loading branch information
brianzinn committed Jun 1, 2024
1 parent 2681ae6 commit bb37bcb
Show file tree
Hide file tree
Showing 7 changed files with 1,438 additions and 1,411 deletions.
10 changes: 5 additions & 5 deletions devtool/loader/src/codesandbox-templates/js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
"keywords": [],
"main": "src/index.jsx",
"dependencies": {
"@babylonjs/core": "^6.48.1",
"@babylonjs/gui": "^6.48.1",
"@babylonjs/core": "^7.9.0",
"@babylonjs/gui": "^7.9.0",
"@babylonjs/havok": "^1.3.2",
"@babylonjs/loaders": "^6.48.1",
"@babylonjs/materials": "^6.48.1",
"@babylonjs/procedural-textures": "^6.48.1",
"@babylonjs/loaders": "^7.9.0",
"@babylonjs/materials": "^7.9.0",
"@babylonjs/procedural-textures": "^7.9.0",
"babylonjs-hook": "0.1.1",
"react": "^18.2.0",
"react-babylonjs": "3.1.30",
Expand Down
4 changes: 2 additions & 2 deletions packages/react-babylonjs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"test:coverage": "c8 --reporter=lcov --reporter=text-summary npm run test"
},
"devDependencies": {
"@babylonjs/core": "^6.48.1",
"@babylonjs/gui": "^6.48.1",
"@babylonjs/core": "^7.9.0",
"@babylonjs/gui": "^7.9.0",
"@rollup/plugin-json": "^4.0.2",
"@rollup/plugin-replace": "^3.0.0",
"@types/lodash.camelcase": "^4.3.6",
Expand Down
5 changes: 2 additions & 3 deletions packages/react-babylonjs/src/engine/Engine.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Engine } from '@babylonjs/core/Engines/engine.js'
import { EngineOptions, ThinEngine } from '@babylonjs/core/Engines/thinEngine.js'
import { Observable } from '@babylonjs/core/Misc/observable.js'
import { EngineOptions } from '@babylonjs/core/Engines/thinEngine.js'
import { Nullable } from '@babylonjs/core/types.js'
import React, { ReactNode, useEffect, useRef, useState } from 'react'
import { EngineCanvasContext } from '../hooks/engine'
Expand Down Expand Up @@ -92,7 +91,7 @@ const ReactBabylonjsEngine: React.FC<EngineProps> = (props: EngineProps, context
// }
})

engine.current.onContextLostObservable.add((eventData: ThinEngine) => {
engine.current.onContextLostObservable.add((eventData) => {
console.warn('context loss observable from Engine: ', eventData)
})

Expand Down
3 changes: 1 addition & 2 deletions packages/react-babylonjs/src/engine/WebGPUEngine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
} from '@babylonjs/core/Engines/webgpuEngine.js'
import { TwgslOptions } from '@babylonjs/core/Engines/WebGPU/webgpuTintWASM.js'
import { ThinEngine } from '@babylonjs/core/Engines/thinEngine.js'
import { Observable } from '@babylonjs/core/Misc/observable.js'
import { Nullable } from '@babylonjs/core/types.js'
import React, { ReactNode, useEffect, useRef, useState } from 'react'
import { EngineCanvasContext } from '../hooks/engine'
Expand Down Expand Up @@ -96,7 +95,7 @@ const ReactBabylonjsWebGPUEngine: React.FC<WebGPUEngineProps> = (
})
})

webGPUEngine.onContextLostObservable.add((eventData: ThinEngine) => {
webGPUEngine.onContextLostObservable.add((eventData) => {
console.warn('context loss observable from Engine: ', eventData)
})

Expand Down
6 changes: 5 additions & 1 deletion packages/react-babylonjs/src/hooks/engine.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,11 @@ export const useEngine = (): Nullable<Engine | WebGPUEngine> => {
}

if (sceneContext.scene !== null) {
return sceneContext.scene.getEngine()
// Could actually be a "ThinEngine":
// Abstract
// ├──> ThinEngine ──> Engine
// └──> WebGPUEngine
return sceneContext.scene.getEngine() as Engine | WebGPUEngine
}

return null
Expand Down
16 changes: 8 additions & 8 deletions packages/static/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"version": "0.0.1",
"dependencies": {
"@babel/plugin-proposal-export-default-from": "^7.12.13",
"@babylonjs/core": "^6.48.1",
"@babylonjs/gui": "^6.48.1",
"@babylonjs/gui-editor": "^6.48.1",
"@babylonjs/core": "^7.9.0",
"@babylonjs/gui": "^7.9.0",
"@babylonjs/gui-editor": "^7.9.0",
"@babylonjs/havok": "^1.3.2",
"@babylonjs/inspector": "^6.48.1",
"@babylonjs/loaders": "^6.48.1",
"@babylonjs/materials": "^6.48.1",
"@babylonjs/procedural-textures": "^6.48.1",
"@babylonjs/serializers": "^6.48.1",
"@babylonjs/inspector": "^7.9.0",
"@babylonjs/loaders": "^7.9.0",
"@babylonjs/materials": "^7.9.0",
"@babylonjs/procedural-textures": "^7.9.0",
"@babylonjs/serializers": "^7.9.0",
"@devtool/gatsby-mdx-plugin": "*",
"@emotion/react": "^11.10.4",
"@emotion/styled": "^11.10.4",
Expand Down
Loading

0 comments on commit bb37bcb

Please sign in to comment.