Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean up remaining upstream diff #74

Merged
merged 9 commits into from
Feb 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/client-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@
"dependencies": {
"@emotion/react": "11.10.6",
"@emotion/styled": "11.10.6",
"@ir-engine/common": "^1.6.0",
"@ir-engine/engine": "^1.6.0",
"@ir-engine/hyperflux": "^1.6.0",
"@ir-engine/ui": "^1.6.0",
"@feathersjs/authentication-client": "5.0.5",
"@feathersjs/client": "5.0.5",
"@feathersjs/primus-client": "4.5.15",
"@feathersjs/rest-client": "5.0.5",
"@hookstate/core": "npm:@speigg/[email protected]",
"@ir-engine/common": "^1.6.0",
"@ir-engine/engine": "^1.6.0",
"@ir-engine/hyperflux": "^1.6.0",
"@ir-engine/ui": "^1.6.0",
"@mui/icons-material": "5.15.15",
"@mui/material": "5.11.13",
"@uiw/react-color-sketch": "^2.1.1",
Expand Down
5 changes: 2 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,12 @@
"react-i18next": "11.16.6",
"react-icons": "5.0.1",
"react-json-tree": "^0.18.0",
"react-native-web": "^0.19.13",
"react-router-dom": "6.9.0",
"sass": "1.59.3",
"tailwind-merge": "^1.13.2",
"tailwindcss": "^3.3.2",
"ts-node": "10.9.1",
"vite": "5.4.8",
"ts-node": "10.9.1",
"vite-plugin-compression2": "1.3.0",
"vite-plugin-ejs": "^1.6.4",
"vite-plugin-node-polyfills": "^0.9.0",
Expand All @@ -89,4 +88,4 @@
"trace-unhandled": "2.0.1"
},
"license": "ISC"
}
}
3 changes: 1 addition & 2 deletions packages/client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,7 @@ export default defineConfig(async () => {
].filter(Boolean),
resolve: {
alias: {
'react-json-tree': 'react-json-tree/lib/umd/react-json-tree',
'react-native': 'react-native-web'
'react-json-tree': 'react-json-tree/lib/umd/react-json-tree'
}
},
build: {
Expand Down
17 changes: 3 additions & 14 deletions packages/clientNative/globals.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {TextEncoder, TextDecoder} from 'text-encoding-shim';
import structuredClone from '@ungap/structured-clone';
import performance from 'react-native-performance';
import {URL} from 'whatwg-url-without-unicode';
import {Dimensions} from 'react-native';

window.location = new URL('https://mariale.ir.world/location/marbar');

Expand All @@ -59,14 +58,8 @@ global.localStorage = {

// Window polyfill
const listenerRegistry = new Map();
const resizeSubscriptions = new Map();

window.addEventListener = (type, handler) => {
// if (type === 'resize') {
// const subscription = Dimensions.addEventListener('change', handler);
// resizeSubscriptions.set(handler, subscription);
// return;
// }
let registry = listenerRegistry.get(type);

if (!registry) {
Expand All @@ -76,13 +69,6 @@ window.addEventListener = (type, handler) => {
registry.add(handler);
};
window.removeEventListener = (type, handler) => {
// if (type === 'resize') {
// const subscription = resizeSubscriptions.get(handler);
// subscription?.remove();
// resizeSubscriptions.delete(handler);
// return;
// }

const registry = listenerRegistry.get(type);
if (registry) {
registry.delete(handler);
Expand All @@ -97,6 +83,9 @@ window.dispatchEvent = (eventType, evt) => {
}
};

document.addEventListener = window.addEventListener;
document.removeEventListener = window.removeEventListener;

// Using PixelRatio.get() was causing issues with frame buffers. Let's default to 1.
window.devicePixelRatio = 1;

Expand Down
4 changes: 3 additions & 1 deletion packages/clientNative/metro.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,9 @@ module.exports = makeMetroConfig({
}
if (
moduleName.startsWith('@ir-engine/editor') ||
moduleName.startsWith('@ir-engine/visual-script')
moduleName.startsWith('@ir-engine/visual-script') ||
moduleName.endsWith('VisualScriptModule') ||
moduleName.startsWith('react-dom')
) {
return {
filePath: path.resolve(__dirname, `./emptyPolyfill.js`),
Expand Down
15 changes: 9 additions & 6 deletions packages/common/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,16 @@ All portions of the code written by the Infinite Reality Engine team are Copyrig
Infinite Reality Engine. All Rights Reserved.
*/

import { isReactNative } from '@ir-engine/spatial/src/common/functions/isMobile'
import { EMAIL_REGEX } from './regex'
import type { MediaSettingsType } from './schema.type.module'

/**
* Config settings (for client and isomorphic engine usage).
*/
const localBuildOrDev = false
const localBuildOrDev =
!isReactNative &&
(globalThis.process.env.APP_ENV === 'development' || globalThis.process.env.VITE_LOCAL_BUILD === 'true')

export function validateEmail(email: string): boolean {
return EMAIL_REGEX.test(email)
Expand All @@ -54,26 +57,26 @@ const client = {
localBuildOrDev,
clientUrl:
localBuildOrDev && process.env.VITE_LOCAL_NGINX !== 'true'
? `http://${process.env.VITE_APP_HOST}:${process.env.VITE_APP_PORT}`
? `https://${process.env.VITE_APP_HOST}:${process.env.VITE_APP_PORT}`
: `https://${process.env.VITE_APP_HOST}`,
serverHost: process.env.VITE_SERVER_HOST,
rootDomainEnabled: process.env.VITE_ROOT_DOMAIN_ENABLED === 'false' ? false : true, // default to true
serverUrl:
localBuildOrDev && process.env.VITE_LOCAL_NGINX !== 'true'
? `http://${process.env.VITE_SERVER_HOST}:${process.env.VITE_SERVER_PORT}`
? `https://${process.env.VITE_SERVER_HOST}:${process.env.VITE_SERVER_PORT}`
: `https://${process.env.VITE_SERVER_HOST}`,
instanceserverUrl:
localBuildOrDev && process.env.VITE_LOCAL_NGINX !== 'true'
? `http://${process.env.VITE_INSTANCESERVER_HOST}:${process.env.VITE_INSTANCESERVER_PORT}`
? `https://${process.env.VITE_INSTANCESERVER_HOST}:${process.env.VITE_INSTANCESERVER_PORT}`
: `https://${process.env.VITE_INSTANCESERVER_HOST}`,
fileServer:
(process.env.TEST === 'true' ? process.env.VITE_TEST_FILE_SERVER : process.env.VITE_FILE_SERVER) ??
'http://localhost:8642',
'https://localhost:8642',
mediatorServer: process.env.VITE_MEDIATOR_SERVER,
cors: {
proxyUrl:
localBuildOrDev && process.env.VITE_LOCAL_NGINX !== 'true'
? `http://${process.env.VITE_SERVER_HOST}:${process.env.VITE_CORS_SERVER_PORT}`
? `https://${process.env.VITE_SERVER_HOST}:${process.env.VITE_CORS_SERVER_PORT}`
: `https://${process.env.VITE_SERVER_HOST}/cors-proxy`,
serverPort: process.env.VITE_CORS_SERVER_PORT
},
Expand Down
8 changes: 4 additions & 4 deletions packages/engine/src/EngineModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/ir-engine/ir-engine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis,
Expand All @@ -19,7 +19,7 @@ The Original Code is Infinite Reality Engine.
The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Infinite Reality Engine team.

All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
Infinite Reality Engine. All Rights Reserved.
*/

Expand All @@ -33,4 +33,4 @@ export * from './interaction/systems/InteractableSystem'
export * from './mocap/MocapModule'
export * from './postprocessing/PopulateEffectRegistry'
export * from './scene/SceneModule'
// export * from './visualscript/VisualScriptModule'
export * from './visualscript/VisualScriptModule'
7 changes: 3 additions & 4 deletions packages/engine/src/gltf/GLTFExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/EtherealEngine/etherealengine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis,
Expand All @@ -19,7 +19,7 @@ The Original Code is Ethereal Engine.
The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Ethereal Engine team.

All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023
All portions of the code written by the Ethereal Engine team are Copyright © 2021-2023
Ethereal Engine. All Rights Reserved.
*/

Expand Down Expand Up @@ -129,7 +129,6 @@ export const EXT_MESHOPT_COMPRESSION = {
const decoder = getState(AssetLoaderState).gltfLoader.meshoptDecoder
if (!decoder || !decoder.supported) {
if (json.extensionsRequired && json.extensionsRequired.indexOf(EXTENSIONS.EXT_MESHOPT_COMPRESSION) >= 0) {
console.error('THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files')
return reject('THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files')
} else {
// Assumes that the extension is optional and that fallback buffer data is present
Expand Down
12 changes: 8 additions & 4 deletions packages/engine/src/scene/systems/ShadowSystem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,14 @@ import { XRLightProbeState } from '@ir-engine/spatial/src/xr/XRLightProbeSystem'
import { isMobileXRHeadset } from '@ir-engine/spatial/src/xr/XRState'

import { ReferenceSpaceState } from '@ir-engine/spatial'
import { isReactNative } from '@ir-engine/spatial/src/common/functions/isMobile'
import { RenderModes } from '@ir-engine/spatial/src/renderer/constants/RenderModes'
import { useRendererEntity } from '@ir-engine/spatial/src/renderer/functions/useRendererEntity'
import { createDisposable } from '@ir-engine/spatial/src/resources/resourceHooks'
import { TransformSystem } from '@ir-engine/spatial/src/transform/systems/TransformSystem'
import { useTexture } from '../../assets/functions/resourceLoaderHooks'
import { DomainConfigState } from '../../assets/state/DomainConfigState'
import { useHasModelOrIndependentMesh } from '../../gltf/GLTFComponent'
import { DropShadowComponent } from '../components/DropShadowComponent'
import { RenderSettingsComponent } from '../components/RenderSettingsComponent'
import { ShadowComponent } from '../components/ShadowComponent'
Expand Down Expand Up @@ -309,9 +311,7 @@ const vec3 = new Vector3()

const DropShadowReactor = () => {
const entity = useEntityContext()
// Deviation: this causes an infinite loop in react native due to the use of 'useForceUpdate'
// const hasMeshOrModel = useHasModelOrIndependentMesh(entity)
const hasMeshOrModel = false
const hasMeshOrModel = useHasModelOrIndependentMesh(entity)
const shadow = useComponent(entity, ShadowComponent)

useEffect(() => {
Expand Down Expand Up @@ -444,11 +444,15 @@ const reactor = () => {
shadowMaterial.needsUpdate = true
}, [shadowTexture])

/**
* DropShadowReactor causes an infinite setState loop in react native due to the use of 'useForceUpdate'
* in useAncestorWithComponent.
**/
return (
<>
{useShadows ? (
<QueryReactor Components={[RenderSettingsComponent]} ChildEntityReactor={RenderSettingsQueryReactor} />
) : shadowTexture ? (
) : shadowTexture && !isReactNative ? (
<QueryReactor Components={[VisibleComponent, ShadowComponent]} ChildEntityReactor={DropShadowReactor} />
) : null}
<QueryReactor Components={[RendererComponent]} ChildEntityReactor={RendererShadowReactor} />
Expand Down
34 changes: 19 additions & 15 deletions packages/engine/src/xrui/createXRUI.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,14 @@ import { Group } from 'three'

import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
import { Entity } from '@ir-engine/ecs/src/Entity'
import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { EntityContext, createEntity } from '@ir-engine/ecs/src/EntityFunctions'
import { State, getState, isClient } from '@ir-engine/hyperflux'
import { WebContainer3D } from '@ir-engine/xrui/core/three/WebContainer3D'
import { WebLayerManager } from '@ir-engine/xrui/core/three/WebLayerManager'

import { AssetLoaderState } from '@ir-engine/engine/src/assets/state/AssetLoaderState'
import { ReferenceSpaceState } from '@ir-engine/spatial'
import { isReactNative } from '@ir-engine/spatial/src/common/functions/isMobile'
import { InputComponent } from '@ir-engine/spatial/src/input/components/InputComponent'
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
Expand All @@ -47,6 +48,8 @@ import { ObjectLayers } from '@ir-engine/spatial/src/renderer/constants/ObjectLa
import { DistanceFromCameraComponent } from '@ir-engine/spatial/src/transform/components/DistanceComponents'
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
import { XRUIComponent } from '@ir-engine/spatial/src/xrui/components/XRUIComponent'
import { createRoot } from 'react-dom/client'
import { XRUIStateContext } from './XRUIStateContext'

export function createXRUI<S extends State<any> | null>(
UIFunc: React.FC,
Expand All @@ -60,27 +63,28 @@ export function createXRUI<S extends State<any> | null>(
containerElement.style.position = 'fixed'
containerElement.id = 'xrui-' + UIFunc.name

// TODO: We can't do this in React Native...
// const rootElement = createRoot(containerElement!)
// rootElement.render(
// //@ts-ignore
// <EntityContext.Provider value={entity}>
// {/*
// // @ts-ignore */}
// <XRUIStateContext.Provider value={state}>
// <UIFunc />
// </XRUIStateContext.Provider>
// </EntityContext.Provider>
// )

if (!WebLayerManager.instance) {
const viewerEntity = getState(ReferenceSpaceState).viewerEntity
const renderer = getComponent(viewerEntity, RendererComponent)
const gltfLoader = getState(AssetLoaderState).gltfLoader
WebLayerManager.initialize(renderer.renderer!, gltfLoader.ktx2Loader!)
}

return { entity: createEntity() }
if (isReactNative) {
return { entity: createEntity() } as XRUI<S>
}

const rootElement = createRoot(containerElement!)
rootElement.render(
//@ts-ignore
<EntityContext.Provider value={entity}>
{/*
// @ts-ignore */}
<XRUIStateContext.Provider value={state}>
<UIFunc />
</XRUIStateContext.Provider>
</EntityContext.Provider>
)

const container = new WebContainer3D(containerElement, { manager: WebLayerManager.instance })

Expand Down
2 changes: 1 addition & 1 deletion packages/instanceserver/src/start.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ export const start = async (): Promise<Application> => {
// SSL setup
const certPath = config.server.certPath
const certKeyPath = config.server.keyPath
const useSSL = false
const useSSL = !config.noSSL && (config.localBuild || !config.kubernetes.enabled) && fs.existsSync(certKeyPath)

const certOptions = {
key: useSSL ? fs.readFileSync(certKeyPath) : null,
Expand Down
46 changes: 46 additions & 0 deletions packages/projects/loadConfigForProject.native.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
CPAL-1.0 License

The contents of this file are subject to the Common Public Attribution License
Version 1.0. (the "License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
https://github.com/ir-engine/ir-engine/blob/dev/LICENSE.
The License is based on the Mozilla Public License Version 1.1, but Sections 14
and 15 have been added to cover use of software over a computer network and
provide for limited attribution for the Original Developer. In addition,
Exhibit A has been modified to be consistent with Exhibit B.

Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the
specific language governing rights and limitations under the License.

The Original Code is Infinite Reality Engine.

The Original Developer is the Initial Developer. The Initial Developer of the
Original Code is the Infinite Reality Engine team.

All portions of the code written by the Infinite Reality Engine team are Copyright © 2021-2023
Infinite Reality Engine. All Rights Reserved.
*/

import type { ProjectConfigInterface } from './ProjectConfigInterface.ts'

const configs = {} as Record<string, ProjectConfigInterface>

export const loadConfigForProject = async (project: string): Promise<ProjectConfigInterface | null> => {
try {
if (configs[project]) return configs[project]
/**
* TODO React Native: This currently hardcodes the project to irpro-mariale for demo purposes.
* In the future, this should be baked into the build system or somehow fetched dynamically
*/
const projectConfig = (await import(
`./projects/theinfinitereality/irpro-mariale/xrengine.config.ts`
)) as ProjectConfigInterface
configs[project] = projectConfig
return projectConfig
} catch (e) {
console.log(`Failed to import config for project ${project} with reason ${e}`)
return null!
}
}
Loading
Loading