Skip to content

Commit 609460f

Browse files
committed
Merge branch 'dev' into IR-4678-Fix-cross-imports-from-spatial-to-engine-package
2 parents fe4d016 + 7476fbf commit 609460f

17 files changed

+135
-63
lines changed

resources.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@
616616
"name": "HDVideo.mp4"
617617
},
618618
"public/avatars/Adam.gltf": {
619-
"type": "asset",
619+
"type": "avatar",
620620
"tags": [
621621
"Model"
622622
],
@@ -688,15 +688,15 @@
688688
"name": "ffd667f5c4c57f61a582c47337035d704ae616104df6ee505b3c715455c4c11c.ktx2"
689689
},
690690
"public/avatars/Test Avaturn.glb": {
691-
"type": "asset",
691+
"type": "avatar",
692692
"tags": [
693693
"Model"
694694
],
695695
"dependencies": [],
696696
"name": "Test Avaturn.glb"
697697
},
698698
"public/avatars/Test RPM.glb": {
699-
"type": "asset",
699+
"type": "avatar",
700700
"tags": [
701701
"Model"
702702
],

src/engine/benchmarks/AvatarBenchmark.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { useHookstate } from '@ir-engine/hyperflux'
2525
import { NetworkObjectComponent } from '@ir-engine/network'
2626
import { TransformComponent } from '@ir-engine/spatial'
2727
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
28-
import { Object3DComponent } from '@ir-engine/spatial/src/renderer/components/Object3DComponent'
28+
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
2929
import { VisibleComponent, setVisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
3030
import React, { useEffect } from 'react'
3131
import { Group, MathUtils, Quaternion, Vector3 } from 'three'
@@ -189,7 +189,7 @@ const AvatarIKSetupReactor = (props: {
189189
const uuid = MathUtils.generateUUID()
190190
setComponent(entity, UUIDComponent, uuid as EntityUUID)
191191
setComponent(entity, EntityTreeComponent, { parentEntity: rootEntity })
192-
setComponent(entity, Object3DComponent, obj3d)
192+
setComponent(entity, ObjectComponent, obj3d)
193193
setComponent(entity, TransformComponent, { position })
194194
setComponent(entity, VisibleComponent, true)
195195
setComponent(entity, RigidBodyComponent, { type: 'kinematic' })

src/engine/benchmarks/ParticlesBenchmark.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Engine, Entity, getComponent, removeEntity, setComponent } from '@ir-engine/ecs'
22
import { ParticleSystemComponent } from '@ir-engine/engine/src/scene/components/ParticleSystemComponent'
33
import { TransformComponent } from '@ir-engine/spatial'
4-
import { Object3DComponent } from '@ir-engine/spatial/src/renderer/components/Object3DComponent'
4+
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
55
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
66
import { useEffect } from 'react'
77
import { Group, MathUtils } from 'three'
@@ -19,7 +19,7 @@ const createParticleEntity = (rootEntity: Entity) => {
1919
position.setX(position.x + MathUtils.randFloat(-2.0, 2.0))
2020
const obj3d = new Group()
2121
obj3d.entity = entity
22-
setComponent(entity, Object3DComponent, obj3d)
22+
setComponent(entity, ObjectComponent, obj3d)
2323
setComponent(entity, TransformComponent, { position })
2424
setComponent(entity, ParticleSystemComponent)
2525
setComponent(entity, VisibleComponent, true)

src/engine/benchmarks/PhysicsBenchmark.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { GeometryTypeEnum } from '@ir-engine/engine/src/scene/constants/Geometry
44
import { TransformComponent } from '@ir-engine/spatial'
55
import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/ColliderComponent'
66
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
7-
import { Object3DComponent } from '@ir-engine/spatial/src/renderer/components/Object3DComponent'
7+
import { ObjectComponent } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
88
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
99
import { useEffect } from 'react'
1010
import { Group, MathUtils, Vector3 } from 'three'
@@ -24,7 +24,7 @@ const createPhysicsEntity = (rootEntity: Entity) => {
2424
position.setX(position.x + MathUtils.randFloat(-2.0, 2.0))
2525
const obj3d = new Group()
2626
obj3d.entity = entity
27-
setComponent(entity, Object3DComponent, obj3d)
27+
setComponent(entity, ObjectComponent, obj3d)
2828
setComponent(entity, TransformComponent, { position, scale })
2929
setComponent(entity, PrimitiveGeometryComponent, {
3030
geometryType: GeometryTypeEnum.SphereGeometry,

src/examples/LODs.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import { TransformComponent } from '@ir-engine/spatial/src/transform/components/
2222

2323
import config from '@ir-engine/common/src/config'
2424
import { Entity } from '@ir-engine/ecs/src/Entity'
25-
import { GroupComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
25+
import { GroupComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
2626
import { Template } from './utils/template'
2727

2828
// create rings for each LOD

src/examples/Retargeting.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { getGLTFAsync } from '@ir-engine/engine/src/assets/functions/resourceLoa
2525
import { MixamoBoneNames } from '@ir-engine/engine/src/avatar/AvatarBoneMatching'
2626
import { TransformComponent } from '@ir-engine/spatial'
2727
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
28-
import { GroupComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
28+
import { GroupComponent, addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
2929
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
3030
import { VRMHumanBoneName } from '@pixiv/three-vrm'
3131
import { Template } from './utils/template'

src/examples/ShadowExample.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
} from '@ir-engine/spatial'
2323
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
2424
import { RendererComponent } from '@ir-engine/spatial/src/renderer/WebGLRendererSystem'
25-
import { addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
2625
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
2726
import { SceneComponent } from '@ir-engine/spatial/src/renderer/components/SceneComponents'
2827
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
@@ -60,14 +59,12 @@ const SceneReactor = (props: { sceneEntity: Entity }) => {
6059
setComponent(platformEntity, VisibleComponent)
6160
setComponent(platformEntity, NameComponent, 'Platform')
6261
setComponent(platformEntity, MeshComponent, new Mesh(new BoxGeometry(), new MeshLambertMaterial()))
63-
addObjectToGroup(platformEntity, getComponent(platformEntity, MeshComponent))
6462
setComponent(platformEntity, ShadowComponent, { cast: false })
6563

6664
setComponent(boxEntity, TransformComponent, { position: new Vector3(0, 0.5, 0) })
6765
setComponent(boxEntity, VisibleComponent)
6866
setComponent(boxEntity, NameComponent, 'Box')
6967
setComponent(boxEntity, MeshComponent, new Mesh(new BoxGeometry(), new MeshLambertMaterial()))
70-
addObjectToGroup(boxEntity, getComponent(boxEntity, MeshComponent))
7168
setComponent(boxEntity, ShadowComponent, { receive: false })
7269

7370
setComponent(directionalLightEntity, TransformComponent, {

src/examples/Splines.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { createEntity } from '@ir-engine/ecs/src/EntityFunctions'
66
import { SplineComponent } from '@ir-engine/engine/src/scene/components/SplineComponent'
77
import { SplineTrackComponent } from '@ir-engine/engine/src/scene/components/SplineTrackComponent'
88
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
9-
import { addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
9+
import { addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
1010
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
1111
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
1212
import { BoxGeometry, Mesh, MeshBasicMaterial, Quaternion, SphereGeometry, Vector3 } from 'three'

src/examples/XRLightEstimation.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { XRLightProbeState } from '@ir-engine/spatial/src/xr/XRLightProbeSystem'
77
import { getComponent, setComponent } from '@ir-engine/ecs/src/ComponentFunctions'
88
import { createEntity, removeEntity } from '@ir-engine/ecs/src/EntityFunctions'
99
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
10-
import { addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
10+
import { addObjectToGroup } from '@ir-engine/spatial/src/renderer/components/ObjectComponent'
1111
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
1212
import { TransformComponent } from '@ir-engine/spatial/src/transform/components/TransformComponent'
1313
import { Template } from './utils/template'

src/examples/XRMeshes.tsx

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BufferGeometry, Mesh, MeshBasicMaterial, MeshNormalMaterial, Vector3 }
44
import { setComponent, useComponent } from '@ir-engine/ecs/src/ComponentFunctions'
55
import { createEntity, removeEntity, useEntityContext } from '@ir-engine/ecs/src/EntityFunctions'
66
import { NameComponent } from '@ir-engine/spatial/src/common/NameComponent'
7-
import { addObjectToGroup, removeObjectFromGroup } from '@ir-engine/spatial/src/renderer/components/GroupComponent'
87

98
import { EntityTreeComponent } from '@ir-engine/ecs'
109
import { QueryReactor } from '@ir-engine/ecs/src/QueryFunctions'
@@ -13,6 +12,8 @@ import { ColliderComponent } from '@ir-engine/spatial/src/physics/components/Col
1312
import { RigidBodyComponent } from '@ir-engine/spatial/src/physics/components/RigidBodyComponent'
1413
import { CollisionGroups, DefaultCollisionMask } from '@ir-engine/spatial/src/physics/enums/CollisionGroups'
1514
import { BodyTypes, Shapes } from '@ir-engine/spatial/src/physics/types/PhysicsTypes'
15+
import { MeshComponent } from '@ir-engine/spatial/src/renderer/components/MeshComponent'
16+
import { VisibleComponent } from '@ir-engine/spatial/src/renderer/components/VisibleComponent'
1617
import { XRDetectedMeshComponent } from '@ir-engine/spatial/src/xr/XRDetectedMeshComponent'
1718
import { XRDetectedPlaneComponent } from '@ir-engine/spatial/src/xr/XRDetectedPlaneComponent'
1819
import { Template } from './utils/template'
@@ -22,35 +23,38 @@ const normalMaterial = new MeshNormalMaterial({ opacity: 0.5, transparent: true
2223

2324
export const DetectedPlanes = () => {
2425
const entity = useEntityContext()
25-
2626
const xrPlane = useComponent(entity, XRDetectedPlaneComponent)
2727

2828
useEffect(() => {
2929
if (!xrPlane.geometry.value) return
30-
const transparentMesh = new Mesh(xrPlane.geometry.value as BufferGeometry, normalMaterial)
31-
addObjectToGroup(entity, transparentMesh)
32-
setComponent(
33-
entity,
34-
NameComponent,
35-
'Plane ' + (xrPlane.plane.value.semanticLabel ?? xrPlane.plane.orientation.value)
36-
)
37-
30+
const planeName =
31+
'XR Plane ' + entity + '(' + (xrPlane.plane.value.semanticLabel ?? xrPlane.plane.orientation.value) + ')'
3832
const geometry = xrPlane.geometry.value as BufferGeometry
3933
const box = geometry.boundingBox!
4034
const height = box.max.x - box.min.x
4135
const width = box.max.z - box.min.z
4236

4337
/** Create a child entity such that we can have a distinct scale for the collider */
4438

39+
const meshEntity = createEntity()
40+
41+
setComponent(meshEntity, NameComponent, planeName + ' Mesh')
42+
setComponent(meshEntity, EntityTreeComponent, {
43+
parentEntity: entity
44+
})
45+
setComponent(meshEntity, TransformComponent)
46+
setComponent(meshEntity, VisibleComponent)
47+
const transparentMesh = new Mesh(xrPlane.geometry.value as BufferGeometry, normalMaterial)
48+
setComponent(meshEntity, MeshComponent, transparentMesh)
49+
4550
const colliderEntity = createEntity()
46-
setComponent(colliderEntity, NameComponent, 'Plane ' + entity + ' Collider')
51+
setComponent(colliderEntity, NameComponent, planeName + ' Collider')
4752
setComponent(colliderEntity, EntityTreeComponent, {
4853
parentEntity: entity
4954
})
5055
setComponent(colliderEntity, TransformComponent, {
5156
scale: new Vector3(height, 0.01, width)
5257
})
53-
5458
setComponent(colliderEntity, RigidBodyComponent, {
5559
type: BodyTypes.Fixed
5660
})
@@ -60,15 +64,11 @@ export const DetectedPlanes = () => {
6064
collisionMask: DefaultCollisionMask
6165
})
6266
return () => {
67+
removeEntity(meshEntity)
6368
removeEntity(colliderEntity)
64-
removeObjectFromGroup(entity, transparentMesh)
6569
}
6670
}, [xrPlane.geometry])
6771

68-
useEffect(() => {
69-
if (!xrPlane.value || !xrPlane.geometry.value) return
70-
}, [xrPlane?.geometry])
71-
7272
return null
7373
}
7474

@@ -79,20 +79,36 @@ export const DetectedMeshes = () => {
7979

8080
useEffect(() => {
8181
if (!xrmesh.geometry.value) return
82-
const outlineMesh = new Mesh(xrmesh.geometry.value as BufferGeometry, wireframeMaterial)
83-
addObjectToGroup(entity, outlineMesh)
84-
setComponent(entity, NameComponent, 'Plane ' + (xrmesh.mesh.value.semanticLabel ?? entity))
8582

86-
setComponent(entity, RigidBodyComponent, {
83+
const meshName = 'XR Mesh ' + (xrmesh.mesh.value.semanticLabel ?? entity)
84+
85+
const meshEntity = createEntity()
86+
setComponent(meshEntity, NameComponent, meshName + ' Mesh')
87+
setComponent(meshEntity, EntityTreeComponent, {
88+
parentEntity: entity
89+
})
90+
setComponent(meshEntity, TransformComponent)
91+
setComponent(meshEntity, VisibleComponent)
92+
const mesh = new Mesh(xrmesh.geometry.value as BufferGeometry, wireframeMaterial)
93+
setComponent(meshEntity, MeshComponent, mesh)
94+
95+
const colliderEntity = createEntity()
96+
setComponent(colliderEntity, NameComponent, meshName + ' Collider')
97+
setComponent(colliderEntity, EntityTreeComponent, {
98+
parentEntity: entity
99+
})
100+
setComponent(colliderEntity, TransformComponent)
101+
setComponent(colliderEntity, RigidBodyComponent, {
87102
type: BodyTypes.Fixed
88103
})
89-
setComponent(entity, ColliderComponent, {
104+
setComponent(colliderEntity, ColliderComponent, {
90105
shape: Shapes.Mesh,
91106
collisionLayer: CollisionGroups.Ground,
92107
collisionMask: DefaultCollisionMask
93108
})
94109
return () => {
95-
removeObjectFromGroup(entity, outlineMesh)
110+
removeEntity(meshEntity)
111+
removeEntity(colliderEntity)
96112
}
97113
}, [xrmesh.geometry])
98114

0 commit comments

Comments
 (0)