Famous / Famous/engine

Mesh#onDismount is broken

Open
#436 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
1.7k
Forks
249
PR merge metrics
No merged PRs in 30d

Description

## 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)

``` js
'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

``` js
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.

``` js
/**
* 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();
};
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.