<commit_before>/**
 * Created by kaimingyi on 2016/11/18.
 */
const math = require("gl-matrix");
const gkCore = window.gkCore;


class Component {
    constructor() {
        this._host = null;
    }

    get host()
    {
        return this._host;
    }

    set host( target )
    {
        this._host = target;
        this.onStart();
    }

    onStart() {

    }

    onUpdate() {
        //console.info( this );
    }

    onRender() {

    }
}

class Transform extends Component {
    constructor() {
        super();

        this._position = math.vec3.fromValues(0,0,0);
        this._rotation = math.quat.identity(math.quat.create());
        this._scale = math.vec3.fromValues(1,1,1);

        this._dirty = true;

        this._localToWorldMatrx = math.mat4.identity(math.mat4.create());


        this._parent = null;
        this.children = new Set();
    }

    _markDirty()
    {
        this._dirtyComp = true;
        this._dirty = true;
    }

    get parent()
    {
       return this._parent;
    }

    set parent( target )
    {
        this._markDirty();
        if( target instanceof Transform)
        {
            // detach
            if(this._parent !== null) {
                this._parent._removeChild(this);
            }

            this._parent = target;

            // attach
            this._parent._addChild(this);
        }

    }

    _addChild( target )
    {
        this.children.add( target );
    }

    _removeChild( target )
    {
        if(this.children.has( target )) {
            this.children.delete(target);
        }
    }

    get forward() {
        // TODO
        return math.vec3.transformQuat(math.vec3.create(), math.vec3.fromValues(0,0,1), this.localRotation );
    }

    get position() {

        if()

    }


    get localPosition() {
        return this._position;
    }
    set localPosition(value) {
        this._markDirty();
        this._position = value;
    }

    get localRotation() {
        return this._rotation;
    }
    set localRotation(value) {
        this._markDirty();
        this._rotation = value;
    }

    get localScale() {
        return this._scale;
    }
    set localScale(value) {
        this._markDirty();
        this._scale = value;
    }
<commit_msg>position getter<commit_after>/**
 * Created by kaimingyi on 2016/11/18.
 */
const math = require("gl-matrix");
const gkCore = window.gkCore;


class Component {
    constructor() {
        this._host = null;
    }

    get host()
    {
        return this._host;
    }

    set host( target )
    {
        this._host = target;
        this.onStart();
    }

    onStart() {

    }

    onUpdate() {
        //console.info( this );
    }

    onRender() {

    }
}

class Transform extends Component {
    constructor() {
        super();

        this._position = math.vec3.fromValues(0,0,0);
        this._rotation = math.quat.identity(math.quat.create());
        this._scale = math.vec3.fromValues(1,1,1);

        this._dirty = true;

        this._localToWorldMatrx = math.mat4.identity(math.mat4.create());


        this._parent = null;
        this.children = new Set();


        this._worldposition = math.vec3.create();
        this._worldrotation = math.quat.create();
    }

    _markDirty()
    {
        this._dirtyComp = true;
        this._dirty = true;
    }

    get parent()
    {
       return this._parent;
    }

    set parent( target )
    {
        this._markDirty();
        if( target instanceof Transform)
        {
            // detach
            if(this._parent !== null) {
                this._parent._removeChild(this);
            }

            this._parent = target;

            // attach
            this._parent._addChild(this);
        }

    }

    _addChild( target )
    {
        this.children.add( target );
    }

    _removeChild( target )
    {
        if(this.children.has( target )) {
            this.children.delete(target);
        }
    }

    get forward() {
        // TODO
        return math.vec3.transformQuat(math.vec3.create(), math.vec3.fromValues(0,0,1), this.localRotation );
    }

    get position() {

        if( this._parent === null )
        {
            return this._position;
        }

        this.CheckCompDirty();

        return this._worldposition;
    }

    CheckCompDirty() {
        if (this._dirtyComp === true) {
            this._worldposition = math.vec3.add(math.vec3.create(), this._parent.transform.position, math.vec3.transformQuat(
                math.vec3.create(), this.localPosition, this._parent.rotation));

            this._worldrotation = math.quat.mul(math.quat.create(), this._parent.rotation, this.localRotation);

            this._dirtyComp = false;
        }
    }

    get rotation() {

        if( this._parent === null )
        {
            return this._rotation;
        }

        this.CheckCompDirty();

        return this._worldrotation;
    }


    get localPosition() {
        return this._position;
    }
    set localPosition(value) {
        this._markDirty();
        this._position = value;
    }

    get localRotation() {
        return this._rotation;
    }
    set localRotation(value) {
        this._markDirty();
        this._rotation = value;
    }

    get localScale() {
        return this._scale;
    }
    set localScale(value) {
        this._markDirty();
        this._scale = value;
    }

{'fraction_non_alphanumeric': 0.12571852401260894, 'fraction_numerical': 0.009827554236973854, 'mean_word_length': 1.6248175182481752, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6569807', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1600, 'n_words': 287}