Skip to content

Commit 0ab3812

Browse files
committed
refactor: replace EntityUUID with SourceID in multiple examples
1 parent b12a405 commit 0ab3812

File tree

7 files changed

+29
-23
lines changed

7 files changed

+29
-23
lines changed

src/examples/MultipleCanvasCameras.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import config from '@ir-engine/common/src/config'
22
import {
33
EntityID,
44
EntityTreeComponent,
5-
EntityUUID,
5+
SourceID,
66
UUIDComponent,
77
UndefinedEntity,
88
createEntity,
@@ -59,7 +59,7 @@ const useScene = (canvas: React.MutableRefObject<HTMLCanvasElement>) => {
5959

6060
setComponent(cameraEntity, NameComponent, '3D Preview Camera for ' + count)
6161
setComponent(cameraEntity, UUIDComponent, {
62-
entitySourceID: 'engine' as EntityUUID,
62+
entitySourceID: 'engine' as SourceID,
6363
entityID: ('camera' + count) as EntityID
6464
})
6565

@@ -80,7 +80,7 @@ export default function MultipleCanvasCameras() {
8080
const sceneEntity = useHookstate(() => {
8181
const sceneEntity = createEntity()
8282
setComponent(sceneEntity, UUIDComponent, {
83-
entitySourceID: 'engine' as EntityUUID,
83+
entitySourceID: 'engine' as SourceID,
8484
entityID: 'scene' as EntityID
8585
})
8686
setComponent(sceneEntity, TransformComponent)
@@ -109,7 +109,7 @@ export default function MultipleCanvasCameras() {
109109
const camera2Entity = panel2State.cameraEntity
110110
const modelEntity = createEntity()
111111
setComponent(modelEntity, UUIDComponent, {
112-
entitySourceID: 'engine' as EntityUUID,
112+
entitySourceID: 'engine' as SourceID,
113113
entityID: 'model' as EntityID
114114
})
115115
setComponent(modelEntity, TransformComponent)

src/examples/MultipleCanvasScenes.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import config from '@ir-engine/common/src/config'
22
import {
33
EntityID,
44
EntityTreeComponent,
5-
EntityUUID,
5+
SourceID,
66
UUIDComponent,
77
UndefinedEntity,
88
createEntity,
@@ -29,7 +29,7 @@ const useScene = (canvas: React.MutableRefObject<HTMLCanvasElement>) => {
2929
const panelState = useHookstate(() => {
3030
const sceneEntity = createEntity()
3131
setComponent(sceneEntity, UUIDComponent, {
32-
entitySourceID: 'engine' as EntityUUID,
32+
entitySourceID: 'engine' as SourceID,
3333
entityID: 'scene' as EntityID
3434
})
3535
setComponent(sceneEntity, TransformComponent)
@@ -39,7 +39,7 @@ const useScene = (canvas: React.MutableRefObject<HTMLCanvasElement>) => {
3939

4040
const cameraEntity = createEntity()
4141
setComponent(cameraEntity, UUIDComponent, {
42-
entitySourceID: 'engine' as EntityUUID,
42+
entitySourceID: 'engine' as SourceID,
4343
entityID: 'camera' as EntityID
4444
})
4545
setComponent(cameraEntity, CameraComponent)
@@ -101,7 +101,7 @@ export default function MultipleCanvasScenes() {
101101
const { cameraEntity, sceneEntity } = panel1State
102102
const modelEntity = createEntity()
103103
setComponent(modelEntity, UUIDComponent, {
104-
entitySourceID: 'engine' as EntityUUID,
104+
entitySourceID: 'engine' as SourceID,
105105
entityID: 'model 1' as EntityID
106106
})
107107
setComponent(modelEntity, TransformComponent)
@@ -118,7 +118,7 @@ export default function MultipleCanvasScenes() {
118118
const { cameraEntity, sceneEntity } = panel2State
119119
const modelEntity = createEntity()
120120
setComponent(modelEntity, UUIDComponent, {
121-
entitySourceID: 'engine' as EntityUUID,
121+
entitySourceID: 'engine' as SourceID,
122122
entityID: 'model 2' as EntityID
123123
})
124124
setComponent(modelEntity, TransformComponent)

src/examples/avatarMocap.tsx

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,15 @@ function AvatarMocap(props: { sceneEntity: Entity }) {
177177
})
178178
setComponent(entity, VisibleComponent, true)
179179

180-
const id = spawnAvatar(rootUUID.value.entitySourceID, rootUUID.value.entityID, selectedAvatar.value, {
181-
position: new Vector3(),
182-
rotation: new Quaternion()
183-
})
180+
const id = spawnAvatar(
181+
UUIDComponent.concatenateUUID(rootUUID.value),
182+
rootUUID.value.entityID,
183+
selectedAvatar.value,
184+
{
185+
position: new Vector3(),
186+
rotation: new Quaternion()
187+
}
188+
)
184189
userID.set(id)
185190

186191
return () => {

src/examples/avatarSimple.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ export default function AvatarSimpleEntry() {
135135
position: new Vector3((Math.random() - 0.5) * spread, 0, (Math.random() - 0.5) * spread),
136136
parentUUID: parentUUID,
137137
avatarURL: randomAvatar.modelResource!.url,
138-
entitySourceID: parentUUID,
138+
entitySourceID: getComponent(entity.value, UUIDComponent).entitySourceID,
139139
entityID: 'avatar' as EntityID,
140140
name: 'test user ' + i,
141141
$peer: ('test peer ' + i) as PeerID

src/examples/componentExamples/componentExamples.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ export const subComponentExamples = [
348348
geometryParams: { radius: 0.2, segments: 10 }
349349
})
350350
setVisibleComponent(childEntity, true)
351-
setComponent(childEntity, SplineTrackComponent, { splineEntityUUID: UUIDComponent.getUUID(entity) })
351+
setComponent(childEntity, SplineTrackComponent, {
352+
splineEntityUUID: getComponent(entity, UUIDComponent).entityID
353+
})
352354
onLoad(entity)
353355
}, [])
354356

src/examples/multipleScenes.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import {
55
Entity,
66
EntityID,
77
EntityTreeComponent,
8-
EntityUUID,
8+
SourceID,
99
UUIDComponent,
1010
UndefinedEntity,
1111
createEntity,
@@ -59,7 +59,7 @@ export const createPhysicsEntity = (sceneEntity: Entity) => {
5959
const i = physicsEntityCount++
6060

6161
const position = new Vector3(Math.random() * 10 - 5, Math.random() * 2 + 2, Math.random() * 10 - 5)
62-
setComponent(entity, UUIDComponent, { entitySourceID: 'engine' as EntityUUID, entityID: ('Ball-' + i) as EntityID })
62+
setComponent(entity, UUIDComponent, { entitySourceID: 'engine' as SourceID, entityID: ('Ball-' + i) as EntityID })
6363
setComponent(entity, EntityTreeComponent, { parentEntity: sceneEntity })
6464
setComponent(entity, TransformComponent, { position, scale: new Vector3(2, 2, 2) })
6565
setComponent(entity, VisibleComponent, true)
@@ -69,7 +69,7 @@ export const createPhysicsEntity = (sceneEntity: Entity) => {
6969
const colliderEntity = createEntity()
7070
setComponent(colliderEntity, VisibleComponent, true)
7171
setComponent(colliderEntity, UUIDComponent, {
72-
entitySourceID: 'engine' as EntityUUID,
72+
entitySourceID: 'engine' as SourceID,
7373
entityID: ('Ball-' + i + '-collider') as EntityID
7474
})
7575
setComponent(colliderEntity, EntityTreeComponent, { parentEntity: entity })

src/examples/utils/avatar/loadAvatarHelpers.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const mockNetworkAvatars = (avatarList: AvatarType[]) => {
4545
position: new Vector3(0, 0, column),
4646
rotation: new Quaternion().setFromAxisAngle(Vector3_Up, Math.PI),
4747
ownerID: userId,
48-
entitySourceID: parentUUID,
48+
entitySourceID: getComponent(Engine.instance.originEntity, UUIDComponent).entitySourceID,
4949
entityID: 'avatar' as EntityID,
5050
avatarURL: avatar.modelResource!.url,
5151
name: userId + '_avatar'
@@ -66,7 +66,6 @@ export const loadNetworkAvatar = (avatar: AvatarType | string, i: number, u = 'u
6666
userID: userId
6767
})
6868
)
69-
7069
const parentUUID = UUIDComponent.concatenateUUID(getComponent(Engine.instance.originEntity, UUIDComponent))
7170

7271
dispatchAction(
@@ -75,7 +74,7 @@ export const loadNetworkAvatar = (avatar: AvatarType | string, i: number, u = 'u
7574
position: new Vector3(x, 0, i * 2),
7675
rotation: new Quaternion().setFromAxisAngle(Vector3_Up, Math.PI),
7776
ownerID: userId,
78-
entitySourceID: parentUUID,
77+
entitySourceID: getComponent(Engine.instance.originEntity, UUIDComponent).entitySourceID,
7978
entityID: 'avatar' as EntityID,
8079
avatarURL: typeof avatar === 'string' ? avatar : avatar.modelResource!.url,
8180
name: userId + '_avatar'
@@ -176,7 +175,7 @@ export const loadAssetWithIK = (avatar: AvatarType, position: Vector3, i: number
176175

177176
export const loadAssetTPose = async (filename, position: Vector3, i: number) => {
178177
const entity = createEntity()
179-
const parentUUID = UUIDComponent.concatenateUUID(getComponent(Engine.instance.originEntity, UUIDComponent))
178+
const parentUUID = UUIDComponent.getAsSourceID(Engine.instance.originEntity)
180179
setComponent(entity, NameComponent, 'TPose Avatar ' + i)
181180
setComponent(entity, UUIDComponent, {
182181
entitySourceID: parentUUID,
@@ -195,7 +194,7 @@ export const loadAssetTPose = async (filename, position: Vector3, i: number) =>
195194

196195
export const loadAssetWithLoopAnimation = async (filename, position: Vector3, i: number) => {
197196
const entity = createEntity()
198-
const parentUUID = UUIDComponent.concatenateUUID(getComponent(Engine.instance.originEntity, UUIDComponent))
197+
const parentUUID = UUIDComponent.getAsSourceID(Engine.instance.originEntity)
199198
setComponent(entity, NameComponent, 'Anim Avatar ' + i + ' ' + filename.split('/').pop())
200199
setComponent(entity, UUIDComponent, {
201200
entitySourceID: parentUUID,

0 commit comments

Comments
 (0)