File tree Expand file tree Collapse file tree 5 files changed +19
-13
lines changed Expand file tree Collapse file tree 5 files changed +19
-13
lines changed Original file line number Diff line number Diff line change @@ -48,9 +48,7 @@ export class Object extends Entity {
48
48
this . quaternion = this . createNetworkProp ( 'quaternion' , new Quaternion ( ) . fromArray ( props . quaternion || defaultQuaternion ) ) // prettier-ignore
49
49
// this.quaternion.onChange = this.onQuaternionChange.bind(this)
50
50
51
- this . root = new Nodes . group ( {
52
- id : '$root' ,
53
- } )
51
+ this . root = new Nodes . group ( { id : '$root' } )
54
52
this . root . position . copy ( this . position . value )
55
53
this . root . quaternion . copy ( this . quaternion . value )
56
54
@@ -477,8 +475,8 @@ export class Object extends Entity {
477
475
if ( ! node ) return null
478
476
return node . getProxy ( )
479
477
} ,
480
- create ( data ) {
481
- const node = entity . createNode ( data )
478
+ create ( type ) {
479
+ const node = entity . createNode ( { type } )
482
480
return node . getProxy ( )
483
481
} ,
484
482
isAuthority ( ) {
@@ -801,9 +799,7 @@ export class Object extends Entity {
801
799
super . destroy ( )
802
800
this . world . entities . setHot ( this , false )
803
801
this . nodes . forEach ( node => {
804
- if ( node . mounted ) {
805
- node . unmount ( )
806
- }
802
+ node . deactivate ( )
807
803
} )
808
804
this . control ?. release ( false )
809
805
this . control = null
Original file line number Diff line number Diff line change @@ -91,14 +91,14 @@ export function createColliderFactory(world, mesh) {
91
91
actor = world . physics . physics . createRigidDynamic ( transform )
92
92
actor . setRigidBodyFlag ( PHYSX . PxRigidBodyFlagEnum . eKINEMATIC , true )
93
93
actor . setRigidBodyFlag ( PHYSX . PxRigidBodyFlagEnum . eENABLE_CCD , false )
94
- } else {
94
+ } else if ( collision === 'static' ) {
95
95
actor = world . physics . physics . createRigidStatic ( transform )
96
96
}
97
97
actor . attachShape ( shape )
98
98
world . physics . scene . addActor ( actor )
99
99
100
100
let untrack
101
- if ( collision !== 'static ') {
101
+ if ( collision === 'dynamic ') {
102
102
untrack = world . physics . track ( actor , node ?. onPhysicsMovement )
103
103
}
104
104
Original file line number Diff line number Diff line change @@ -131,13 +131,13 @@ export class Box extends Node {
131
131
this . actor = this . ctx . world . physics . physics . createRigidDynamic ( this . transform )
132
132
this . actor . setRigidBodyFlag ( PHYSX . PxRigidBodyFlagEnum . eKINEMATIC , true )
133
133
this . actor . setRigidBodyFlag ( PHYSX . PxRigidBodyFlagEnum . eENABLE_CCD , false )
134
- } else {
134
+ } else if ( this . collision === 'static' ) {
135
135
this . actor = this . ctx . world . physics . physics . createRigidStatic ( this . transform )
136
136
}
137
137
// this.actor.setMass(1)
138
138
this . actor . attachShape ( shape )
139
139
this . ctx . world . physics . scene . addActor ( this . actor )
140
- if ( this . collision !== 'static ') {
140
+ if ( this . collision === 'dynamic ') {
141
141
this . untrack = this . ctx . world . physics . track ( this . actor , this . onPhysicsMovement )
142
142
}
143
143
}
Original file line number Diff line number Diff line change @@ -2,6 +2,8 @@ import { isBoolean } from 'lodash-es'
2
2
3
3
import { Node } from './Node'
4
4
5
+ const collisionTypes = [ 'static' , 'kinematic' , 'dynamic' ]
6
+
5
7
const defaults = {
6
8
visible : true ,
7
9
collision : null ,
@@ -17,7 +19,13 @@ export class Mesh extends Node {
17
19
this . model = data . model
18
20
19
21
this . visible = isBoolean ( data . visible ) ? data . visible : defaults . visible
20
- this . collision = data . collision || defaults . collision
22
+
23
+ // todo: we should validate all options because the old collision=true does weird shit now
24
+ // its best to only set if valid
25
+ this . collision = defaults . collision
26
+ if ( collisionTypes . includes ( data . collision ) ) {
27
+ this . collision = data . collision
28
+ }
21
29
this . collisionLayer = data . collisionLayer || defaults . collisionLayer
22
30
23
31
this . mesh = null
Original file line number Diff line number Diff line change @@ -131,6 +131,8 @@ export class Node {
131
131
}
132
132
133
133
setDirty ( ) {
134
+ // if we haven't mounted no track
135
+ if ( ! this . mounted ) return
134
136
// if already dirty, either this or a parent is being tracked so we're good
135
137
if ( this . isDirty ) return
136
138
this . isDirty = true
You can’t perform that action at this time.
0 commit comments