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

got error in console that may be of interest #182

Open
kylebakerio opened this issue Jan 10, 2021 · 0 comments
Open

got error in console that may be of interest #182

kylebakerio opened this issue Jan 10, 2021 · 0 comments

Comments

@kylebakerio
Copy link
Contributor

kylebakerio commented Jan 10, 2021

core:a-node:error Failure loading node:   TypeError: Cannot read property 'toUpperCase' of undefined
    at NewComponent.initBody (aframe-physics-system.js:17135)
    at NewComponent.init (aframe-physics-system.js:17098)
    at NewComponent.initComponent (component.js:320)
    at NewComponent.updateProperties (component.js:302)
    at HTMLElement.updateComponent (a-entity.js:490)
    at HTMLElement.updateComponents (a-entity.js:463)
    at entityLoadCallback (a-entity.js:249)
    at emitLoaded (a-node.js:127)
    ```
    ```js
    /**
   * Parses an element's geometry and component metadata to create a CANNON.Body instance for the
   * component.
   */
  initBody: function () {
    var el = this.el,
        data = this.data;

    var obj = this.el.object3D;
    var pos = obj.position;
    var quat = obj.quaternion;

    this.body = new CANNON.Body({
      mass: data.type === 'static' ? 0 : data.mass || 0,
      material: this.system.getMaterial('defaultMaterial'),
      position: new CANNON.Vec3(pos.x, pos.y, pos.z),
      quaternion: new CANNON.Quaternion(quat.x, quat.y, quat.z, quat.w),
      linearDamping: data.linearDamping,
      angularDamping: data.angularDamping,
      type: data.type === 'dynamic' ? CANNON.Body.DYNAMIC : CANNON.Body.STATIC,
    });

    // Matrix World must be updated at root level, if scale is to be applied – updateMatrixWorld()
    // only checks an object's parent, not the rest of the ancestors. Hence, a wrapping entity with
    // scale="0.5 0.5 0.5" will be ignored.
    // Reference: https://github.com/mrdoob/three.js/blob/master/src/core/Object3D.js#L511-L541
    // Potential fix: https://github.com/mrdoob/three.js/pull/7019
    this.el.object3D.updateMatrixWorld(true);

    if(data.shape !== 'none') {
      var options = data.shape === 'auto' ? undefined : AFRAME.utils.extend({}, this.data, {
        // This is the line
        type: mesh2shape.Type[data.shape.toUpperCase()]
      });

      var shape = mesh2shape(this.el.object3D, options);

      if (!shape) {
        el.addEventListener('object3dset', this.initBody.bind(this));
        return;
      }
      this.body.addShape(shape, shape.offset, shape.orientation);

      // Show wireframe
      if (this.system.debug) {
        this.shouldUpdateWireframe = true;
      }

      this.isLoaded = true;
    }

    this.el.body = this.body;
    this.body.el = el;

    // If component wasn't initialized when play() was called, finish up.
    if (this.isPlaying) {
      this._play();
    }

    if (this.isLoaded) {
      this.el.emit('body-loaded', {body: this.el.body});
    }
  },

May be worth improving that line real quick?

This happened when adding superhands to stuff. I eventually solved the issue, don't recall what I changed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant