Famous / engine

MIT License
1.75k stars 250 forks source link

DOMElement positioned incorrectly (stuck at initial position) when child of Mesh node #393

Closed alexanderGugel closed 9 years ago

alexanderGugel commented 9 years ago

Example

'use strict';

var DOMElement = require('famous/dom-renderables/DOMElement');
var FamousEngine = require('famous/core/FamousEngine');
var Mesh = require('famous/webgl-renderables/Mesh');
var Torus = require('famous/webgl-geometries/primitives/Torus');
var PointLight = require('famous/webgl-renderables/lights/PointLight');
var Color = require('famous/utilities/Color');

FamousEngine.init();

var root = FamousEngine.createScene().addChild();

var mesh = new Mesh(root);

root
    .setSizeMode('absolute', 'absolute', 'absolute')
    .setAbsoluteSize(500, 500, 500)
    .setAlign(0.5, 0.5)
    .setMountPoint(0.5, 0.5)
    .setOrigin(0.5, 0.5);

var color = new Color('red');
mesh
    .setGeometry(new Torus({ detail: 100 }))
    .setBaseColor(color)
    .setGlossiness(color, 1);

new DOMElement(root.addChild().addChild(), { properties: { background: 'blue' } });

var id = root.addComponent({
    onUpdate: function(t) {
        root.setRotation(t*0.0001, t*0.001, t*0.01);
        root.requestUpdate(id);
    }
});

root.requestUpdate(id);

Screenshot

screen shot 2015-07-06 at 8 31 38 pm

Expected

DOMElement (blue) should be centered and rotating (just like the torus).

Tested with latest on develop cde1447

Didn't look into the cause yet. Seems to be a bug in TransformSystem to me (something wrong with breakpoints?). Will have a deeper look tomorrow unless someone else wants to have a look.

michaelobriena commented 9 years ago

The issue is that the Mesh registers the transform of that node as a breakpoint since it needs to have the world transform updated.

This is because we don't calc world transforms for nodes with nothing on them (it is how we get the fast path for transform updating). Unfortunatley, registering a breakpoint is how you need to request a world transform update when in reality requesting a world transform update and having a breakpoint are two separate concepts.

We need to add the ability to mark a transform as in need of a world transform update without flagging it as a break point.

solomon-gumball commented 9 years ago

+1

DnMllr commented 9 years ago

fixed by pr #394

alexanderGugel commented 9 years ago

Closing.