Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Commit

Permalink
Merge branch 'dev' into project-hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
MoizAdnan committed Oct 11, 2023
2 parents 86de671 + 8ee8f7b commit ede2524
Show file tree
Hide file tree
Showing 165 changed files with 451 additions and 581 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
margin: 4px 0;
display: flex;
flex-flow: row wrap;
width: 100%;
}

.sizeLabel {
Expand Down
101 changes: 65 additions & 36 deletions packages/editor/src/components/inputs/ArrayInputGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ All portions of the code written by the Ethereal Engine team are Copyright © 20
Ethereal Engine. All Rights Reserved.
*/

import { t } from 'i18next'
import AddIcon from '@mui/icons-material/Add'
import DeleteIcon from '@mui/icons-material/Delete'
import IconButton from '@mui/material/IconButton'
import React from 'react'
import styles from './ArrayInputGroup.module.scss'
import FileBrowserInput from './FileBrowserInput'
import InputGroup from './InputGroup'
import NumericStepperInput from './NumericStepperInput'

export interface ArrayInputGroupProp {
name?: string
Expand All @@ -45,29 +46,6 @@ export interface ArrayInputGroupState {
values: string[]
}

const onChangeSize = (textSize: string, values: string[], onChange?: any) => {
// copy the array to prevent https://hookstate.js.org/docs/exceptions/#hookstate-202
let valuesCopy = [...values] as string[]
let preCount = valuesCopy.length
const count = parseInt(textSize)
if (isNaN(count) || preCount === count) return
if (preCount > count) {
valuesCopy.splice(count)
} else {
for (let i = 0; i < count - preCount; i++) {
valuesCopy.push('')
}
}
onChange?.(valuesCopy)
}

const onChangeText = (text: string, index: number, values: string[], onChange?: any) => {
// copy the array to prevent https://hookstate.js.org/docs/exceptions/#hookstate-202
const valuesCopy = [...values]
valuesCopy[index] = text
onChange?.(valuesCopy)
}

const ArrayInputGroup = ({
prefix,
label,
Expand All @@ -76,28 +54,79 @@ const ArrayInputGroup = ({
acceptFileTypes,
acceptDropItems
}: ArrayInputGroupProp) => {
let count = 0
if (values && values.length) count = values.length
const addInput = (count = 1) => {
const valuesCopy = [...values]
for (let i = 0; i < count; i++) {
valuesCopy.push('')
}
onChange?.(valuesCopy)
}

const deleteInput = (index: number) => {
const valuesCopy = [...values]
valuesCopy.splice(index, 1)
onChange?.(valuesCopy)
}

const onChangeText = (text: string, index: number) => {
// copy the array to prevent https://hookstate.js.org/docs/exceptions/#hookstate-202
const valuesCopy = [...values]
valuesCopy[index] = text
onChange?.(valuesCopy)
}

return (
<InputGroup name="label" label={label} labelClasses={styles.sizeLabel}>
<div className={styles.arrayInputGroupContent}>
<InputGroup name="size" label={t('editor:properties.media.lbl-size')}>
<NumericStepperInput
value={count}
onChange={(val) => onChangeSize(val, values, onChange)}
mediumStep={1}
displayPrecision={0}
<InputGroup name={`${prefix} 1`} label={`${prefix} 1`}>
<FileBrowserInput
value={values.length > 0 ? values[0] : ''}
onChange={(value) => {
if (values.length > 0) {
onChangeText(value, 0)
} else {
addInput()
onChangeText(value, 0)
}
}}
acceptFileTypes={acceptFileTypes}
acceptDropItems={acceptDropItems}
/>
<IconButton
disableRipple
onClick={() => {
if (values.length === 0) {
addInput(2)
} else {
addInput(1)
}
}}
style={{
padding: 0
}}
>
<AddIcon sx={{ color: 'primary.contrastText' }} />
</IconButton>
</InputGroup>
{values &&
values.map((value, index) => (
<InputGroup name={`${prefix} ${index + 1}`} label={`${prefix} ${index + 1}`} key={value + '' + index}>
values.length > 0 &&
values.slice(1).map((value, index) => (
<InputGroup name={`${prefix} ${index + 2}`} label={`${prefix} ${index + 2}`} key={value + '' + index}>
<FileBrowserInput
value={value}
onChange={(value) => onChangeText(value, index, values, onChange)}
onChange={(value) => onChangeText(value, index + 1)}
acceptFileTypes={acceptFileTypes}
acceptDropItems={acceptDropItems}
/>
<IconButton
disableRipple
style={{
padding: 0
}}
onClick={() => deleteInput(index + 1)}
>
<DeleteIcon sx={{ color: 'primary.contrastText' }} />
</IconButton>
</InputGroup>
))}
</div>
Expand Down
8 changes: 6 additions & 2 deletions packages/editor/src/components/properties/ImageNodeEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import InputGroup from '../inputs/InputGroup'
import ImageSourceProperties from './ImageSourceProperties'
import NodeEditor from './NodeEditor'
import ScreenshareTargetNodeEditor from './ScreenshareTargetNodeEditor'
import { EditorComponentType, updateProperty } from './Util'
import { EditorComponentType, commitProperty, updateProperty } from './Util'

export const ImageNodeEditor: EditorComponentType = (props) => {
const { t } = useTranslation()
Expand All @@ -52,7 +52,11 @@ export const ImageNodeEditor: EditorComponentType = (props) => {
description={t('editor:properties.image.description')}
>
<InputGroup name="Image Url" label={t('editor:properties.image.lbl-imgURL')}>
<ImageInput value={imageComponent.source.value ?? ''} onChange={updateProperty(ImageComponent, 'source')} />
<ImageInput
value={imageComponent.source.value ?? ''}
onChange={updateProperty(ImageComponent, 'source')}
onRelease={commitProperty(ImageComponent, 'source')}
/>
</InputGroup>
{errors ? (
Object.entries(errors).map(([err, message]) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export const MediaNodeEditor: EditorComponentType = (props) => {
label={t('editor:properties.media.seektime')}
value={media.seekTime.value}
onChange={updateProperty(MediaComponent, 'seekTime')}
onRelease={commitProperty(MediaComponent, 'seekTime')}
/>
<InputGroup name="Is Music" label={t('editor:properties.media.lbl-isMusic')}>
<BooleanInput value={media.isMusic.value} onChange={commitProperty(MediaComponent, 'isMusic')} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import InputGroup from '../inputs/InputGroup'
import SelectInput from '../inputs/SelectInput'
import styles from '../styles.module.scss'
import PropertyGroup from './PropertyGroup'
import { EditorComponentType } from './Util'
import { EditorComponentType, commitProperty, updateProperty } from './Util'

enum PropertyTypes {
BlendFunction,
Expand Down Expand Up @@ -240,10 +240,6 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
) => {
const effectSettingState = postprocessing.effects[effectName][property]

const setPropertyValue = (val) => {
effectSettingState.set(val)
}

let renderVal = <></>

switch (propertyDetail.propertyType) {
Expand All @@ -254,36 +250,50 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
max={propertyDetail.max}
step={propertyDetail.step}
value={effectSettingState.value}
onChange={(value) => setPropertyValue(value)}
onChange={updateProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
onRelease={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
/>
)
break

case PropertyTypes.Boolean:
renderVal = <BooleanInput onChange={(value) => setPropertyValue(value)} value={effectSettingState.value} />
renderVal = (
<BooleanInput
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
break

case PropertyTypes.BlendFunction:
renderVal = (
<SelectInput
options={BlendFunctionSelect}
onChange={(value) => setPropertyValue(value)}
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
break

case PropertyTypes.Color:
renderVal = (
<ColorInput value={new Color(effectSettingState.value)} onSelect={(value) => setPropertyValue('#' + value)} />
<ColorInput
value={new Color(effectSettingState.value)}
onSelect={(value) =>
updateProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)('#' + value)
}
onRelease={(value) =>
commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)('#' + value)
}
/>
)
break

case PropertyTypes.KernelSize:
renderVal = (
<SelectInput
options={KernelSizeSelect}
onChange={(value) => setPropertyValue(value)}
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
Expand All @@ -293,7 +303,7 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
renderVal = (
<SelectInput
options={SMAAPreset}
onChange={(value) => setPropertyValue(value)}
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
Expand All @@ -303,7 +313,7 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
renderVal = (
<SelectInput
options={EdgeDetectionMode}
onChange={(value) => setPropertyValue(value)}
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
Expand All @@ -313,7 +323,7 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
renderVal = (
<SelectInput
options={PredicationMode}
onChange={(value) => setPropertyValue(value)}
onChange={commitProperty(PostProcessingComponent, `effects.${effectName}.${property}` as any)}
value={effectSettingState.value}
/>
)
Expand Down Expand Up @@ -370,9 +380,7 @@ export const PostProcessingSettingsEditor: EditorComponentType = (props) => {
<InputGroup name="Post Processing Enabled" label={t('editor:properties.postprocessing.enabled')}>
<BooleanInput
value={postprocessing.enabled.value}
onChange={(val) => {
postprocessing.enabled.set(val)
}}
onChange={commitProperty(PostProcessingComponent, 'enabled')}
/>
</InputGroup>
{postprocessing.enabled.value && (
Expand Down
1 change: 1 addition & 0 deletions packages/editor/src/functions/EditorControlFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ const createObjectFromSceneElement = (
beforeEntity = null as Entity | null,
updateSelection = true
) => {
parentEntity = parentEntity ?? getState(SceneState).sceneEntity
cancelGrabOrPlacement()

const newEntity = createEntity()
Expand Down
2 changes: 2 additions & 0 deletions packages/engine/src/assets/csm/CSM.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,8 @@ export class CSM {

const texelWidth = (shadowCam.right - shadowCam.left) / light.shadow.mapSize.x
const texelHeight = (shadowCam.top - shadowCam.bottom) / light.shadow.mapSize.y
shadowCam.far = this.lightFar
shadowCam.near = this.lightNear

light.shadow.camera.updateMatrixWorld(true)
_cameraToLightMatrix.multiplyMatrices(light.shadow.camera.matrixWorldInverse, camera.matrixWorld)
Expand Down
2 changes: 1 addition & 1 deletion packages/engine/src/assets/csm/Shader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ IncidentLight directLight;
#if defined( USE_SHADOWMAP ) && ( UNROLLED_LOOP_INDEX < NUM_SPOT_LIGHT_SHADOWS )
spotLightShadow = spotLightShadows[ i ];
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotShadowCoord[ i ] ) : 1.0;
directLight.color *= all( bvec2( directLight.visible, receiveShadow ) ) ? getShadow( spotShadowMap[ i ], spotLightShadow.shadowMapSize, spotLightShadow.shadowBias, spotLightShadow.shadowRadius, vSpotLightCoord[ i ] ) : 1.0;
#endif
RE_Direct( directLight, geometry, material, reflectedLight );
Expand Down
3 changes: 2 additions & 1 deletion packages/instanceserver/src/NetworkFunctions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ import { instanceAuthorizedUserPath } from '@etherealengine/engine/src/schemas/n
import { instancePath, InstanceType } from '@etherealengine/engine/src/schemas/networking/instance.schema'
import { inviteCodeLookupPath } from '@etherealengine/engine/src/schemas/social/invite-code-lookup.schema'
import { messagePath } from '@etherealengine/engine/src/schemas/social/message.schema'
import { identityProviderPath } from '@etherealengine/engine/src/schemas/user/identity-provider.schema'
import { userKickPath } from '@etherealengine/engine/src/schemas/user/user-kick.schema'
import { UserID, UserType } from '@etherealengine/engine/src/schemas/user/user.schema'
import { toDateTimeSql } from '@etherealengine/server-core/src/util/datetime-sql'
Expand Down Expand Up @@ -326,7 +327,7 @@ export async function handleDisconnect(network: SocketWebRTCServerNetwork, peerI
isNotification: true
},
{
'identity-provider': {
[identityProviderPath]: {
userId: userId
}
} as any
Expand Down
15 changes: 14 additions & 1 deletion packages/server-core/declarations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import Primus from 'primus'
import '@feathersjs/transport-commons'

import { ServiceTypes } from '@etherealengine/common/declarations'
import { UserType } from '@etherealengine/engine/src/schemas/user/user.schema'

export type PrimusType = Primus & {
forEach(cb: (spark: Primus.Spark, id: string, connections: { [id: string]: Primus.Spark }) => boolean | void): Primus
Expand All @@ -53,5 +54,17 @@ declare module '@feathersjs/feathers' {
}
}

// The context for hook functions - can be typed with a service class
/**
* Add the user as an optional property to all params
*/
declare module '@feathersjs/knex' {
interface KnexAdapterParams {
user?: UserType
isInternal?: boolean
}
}

/**
* The context for hook functions - can be typed with a service class
*/
export type HookContext<S = any> = FeathersHookContext<Application, S>
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ import {

import { instanceAttendancePath } from '@etherealengine/engine/src/schemas/networking/instance-attendance.schema'
import { userPath } from '@etherealengine/engine/src/schemas/user/user.schema'
import { KnexAdapterParams } from '@feathersjs/knex'
import { Knex } from 'knex'
import { Application } from '../../../declarations'
import { RootParams } from '../../api/root-params'

// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface AnalyticsParams extends RootParams<AnalyticsQuery> {}
export interface AnalyticsParams extends KnexAdapterParams<AnalyticsQuery> {}

/**
* A class for Analytics service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ import {
analyticsPatchValidator,
analyticsQueryValidator
} from '@etherealengine/engine/src/schemas/analytics/analytics.schema'
import authenticate from '../../hooks/authenticate'
import verifyScope from '../../hooks/verify-scope'
import {
analyticsDataResolver,
Expand All @@ -48,7 +47,6 @@ export default {

before: {
all: [
authenticate(),
iff(isProvider('external'), verifyScope('admin', 'admin')),
() => schemaHooks.validateQuery(analyticsQueryValidator),
schemaHooks.resolveQuery(analyticsQueryResolver)
Expand Down
Loading

0 comments on commit ede2524

Please sign in to comment.