microsoft / mixed-reality-extension-sdk

The Mixed Reality Extension SDK enables developers to build 3D world extensions for AltspaceVR, using Node.JS.
MIT License
142 stars 61 forks source link

Missing collider shape causes client exception. Should default to 'auto' #560

Open eanders-ms opened 4 years ago

eanders-ms commented 4 years ago

This will cause an exception on the client:

               Actor.CreatePrimitive(this.assets, {
            definition: {
                shape: PrimitiveShape.Box,
                dimensions: {
                    x: 1, y: 1, z: 1
                },
            },
            actor: {
                collider: {
                    enabled: true
                }
            }
        });
unhandledRejection Error: Must provide valid collider params containing a valid shape
    at new Collider (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\actor\physics\collider.js:53:23)
    at Actor._setCollider (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\actor\actor.js:639:26)
    at Actor.copy (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\actor\actor.js:560:18)
    at updateActors.sactors.forEach.sactor (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\core\contextInternal.js:346:19)
    at Array.forEach (<anonymous>)
    at ContextInternal.updateActors (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\core\contextInternal.js:342:17)
    at ContextInternal.createActorFromPayload (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\core\contextInternal.js:43:14)
    at ContextInternal.Create (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\core\contextInternal.js:30:21)
    at Function.Create (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\actor\actor.js:116:33)
    at Function.CreatePrimitive (C:\code\Microsoft\mixed-reality-extension-sdk-samples\samples\chess-game\node_modules\@microsoft\mixed-reality-extension-sdk\built\actor\actor.js:174:22)

To fix it, you have to know that you must provide a collider shape:

               Actor.CreatePrimitive(this.assets, {
            definition: {
                shape: PrimitiveShape.Box,
                dimensions: {
                    x: 1, y: 1, z: 1
                },
            },
            actor: {
                collider: {
                    enabled: true,
                    geometry: {
                        shape: ColliderType.Auto
                    }
                }
            }
        });

I think we can safely default to auto in this case.

stevenvergenz commented 4 years ago

So the patch field that creates a collider should be enabled and not geometry? What if enabled is false, do we still create it?