Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mesh#onDismount is broken #436

Open
alexanderGugel opened this issue Jul 20, 2015 · 2 comments
Open

Mesh#onDismount is broken #436

alexanderGugel opened this issue Jul 20, 2015 · 2 comments
Labels

Comments

@alexanderGugel
Copy link
Member

Steps to reproduce

  1. Create a node
  2. Mount the node
  3. Add a Mesh to the node
  4. Dismount the node via removeChild on parent

Example (self-contained)

'use strict';

var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Mesh = require('famous/webgl-renderables/Mesh');

FamousEngine.init();

var scene = FamousEngine.createScene();

var parent = scene.addChild();
var child = parent.addChild();

var mesh = new Mesh(parent);
mesh.setGeometry('Sphere');

setTimeout(function () {
    scene.removeChild(parent);
}, 1000);

var domElement = new DOMElement(child, {
    properties: {
        background: 'blue'
    }
});

parent
    .setSizeMode('absolute', 'absolute', 'absolute')
    .setAbsoluteSize(250, 250, 250)
    .setAlign(0.5, 0.5)
    .setMountPoint(0.5, 0.5)
    .setOrigin(0.5, 0.5);

var spinner = parent.addComponent({
    onUpdate: function(time) {
        parent.setRotation(time / 1000, time / 2000, time / 3000);
        parent.requestUpdateOnNextTick(spinner);
    }
});

parent.requestUpdate(spinner);

Relevant code sample

setTimeout(function () {
    scene.removeChild(parent);
}, 1000);

Error

Uncaught TypeError: Cannot read property 'split' of null

Cause

The commands sent by Mesh#onDismount are incorrect. They don't include a node location/ path. Therefore the compositor can't split the command.

/**
 * Queues the command for dismounting Mesh
 *
 * @method
 *
 * @return {undefined} undefined
 */
Mesh.prototype.onDismount = function onDismount () {
    this._initialized = false;
    this._changeQueue.push(Commands.GL_REMOVE_MESH);

    this._requestUpdate();
};
@alexanderGugel
Copy link
Member Author

There is a similar problem with Mesh#onOpacityChange, Mesh#onSizeChange, Mesh#onTransformChange, Mesh#onHide, Mesh#onShow.

Basically, the issue is code like this:

Mesh.prototype.onShow = function onShow () {
    this._changeQueue.push(Commands.GL_MESH_VISIBILITY, true);

    this._requestUpdate();
};

We can't simply append the command to the change queue at this point. The WITH commands hasn't been sent at this point. Therefore the commands won't be interpreted correctly by the Compositor.

@CompSciFutures
Copy link

Bug #439 might also be relevant.

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

No branches or pull requests

2 participants