當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript util.is_armature函數代碼示例

本文整理匯總了TypeScript中util.is_armature函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript is_armature函數的具體用法?TypeScript is_armature怎麽用?TypeScript is_armature使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了is_armature函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: limit_object_position

function limit_object_position(obj:b4w.Object) {
    var bb = m_trans.get_object_bounding_box(obj);

    var obj_parent = m_cons.get_parent(obj);
    if (obj_parent && m_util.is_armature(obj_parent))
        // get translation from the parent (armature) of the animated object
        var obj_pos = m_trans.get_translation(obj_parent, _vec3_tmp);
    else
        var obj_pos = m_trans.get_translation(obj, _vec3_tmp);

    if (bb.max_x > WALL_X_MAX)
        obj_pos[0] -= bb.max_x - WALL_X_MAX;
    else if (bb.min_x < WALL_X_MIN)
        obj_pos[0] += WALL_X_MIN - bb.min_x;

    if (bb.max_z > WALL_Z_MAX)
        obj_pos[2] -= bb.max_z - WALL_Z_MAX;
    else if (bb.min_z < WALL_Z_MIN)
        obj_pos[2] += WALL_Z_MIN - bb.min_z;

    if (obj_parent && m_util.is_armature(obj_parent))
        // translate the parent (armature) of the animated object
        m_trans.set_translation_v(obj_parent, obj_pos);
    else
        m_trans.set_translation_v(obj, obj_pos);
}
開發者ID:nil84,項目名稱:b4w-typescript-define,代碼行數:26,代碼來源:main.ts

示例2: loaded_cb

function loaded_cb(data_id:number) {
    var cam:b4w.Camera = m_scenes.get_active_camera();

    // NOTE: need to reinitialize collision sensors because of new objects have been added
    if (m_ctl.check_sensor_manifold(cam, "COLLISION"))
        m_ctl.remove_sensor_manifold(cam, "COLLISION");

    var objs = m_scenes.get_all_objects();

    // spawn appended object at a certain position
    for (var i = 0; i < objs.length; i++) {
        var obj = objs[i];
        if (m_scenes.get_object_data_id(obj) == data_id) {
            if (m_phy.has_physics(obj)) {
                m_phy.enable_simulation(obj);

                var obj_parent = m_cons.get_parent(obj);
                if (obj_parent && m_util.is_armature(obj_parent))
                    // translate the parent (armature) of the animated object
                    m_trans.set_translation_v(obj_parent, spawner_pos);
                else
                    m_trans.set_translation_v(obj, spawner_pos);
            }
            if (m_util.is_mesh(obj))
                m_scenes.show_object(obj);
        }
    }

    // create sensors to detect collisions
    var sensors = [];
    for (var i = 0; i < objs.length; i++) {
        var obj = objs[i];
        if (m_phy.has_simulated_physics(obj)) {
            var sensor_col = m_ctl.create_collision_sensor(obj, "FURNITURE");
            var sensor_sel = m_ctl.create_selection_sensor(obj);

            if (obj == _selected_obj)
                m_ctl.set_custom_sensor(sensor_sel, 1);

            sensors.push(sensor_col);
            sensors.push(sensor_sel);
        }
    }

    var logic_func = function(s) {
        for (var i = 0; i < s.length; i+=2)
            if (s[i+1])
                return s[i];
        return 0;
    }

    m_ctl.create_sensor_manifold(cam, "COLLISION", m_ctl.CT_TRIGGER, sensors,
            logic_func, trigger_outline);
}
開發者ID:nil84,項目名稱:b4w-typescript-define,代碼行數:54,代碼來源:main.ts

示例3: rotate_object

function rotate_object(obj, angle) {
    var obj_parent = m_cons.get_parent(obj);

    if (obj_parent && m_util.is_armature(obj_parent)) {
        // rotate the parent (armature) of the animated object
        var obj_quat = m_trans.get_rotation(obj_parent, _vec4_tmp);
        m_quat.rotateY(obj_quat, angle, obj_quat);
        m_trans.set_rotation_v(obj_parent, obj_quat);
    } else {
        var obj_quat = m_trans.get_rotation(obj, _vec4_tmp);
        m_quat.rotateY(obj_quat, angle, obj_quat);
        m_trans.set_rotation_v(obj, obj_quat);
    }
    limit_object_position(obj);
}
開發者ID:nil84,項目名稱:b4w-typescript-define,代碼行數:15,代碼來源:main.ts

示例4: main_canvas_move

function main_canvas_move(e) {
    if (_drag_mode)
        if (_selected_obj) {
            // disable camera controls while moving the object
            if (_enable_camera_controls) {
                m_app.disable_camera_controls();
                _enable_camera_controls = false;
            }

            // calculate viewport coordinates
            var cam = m_scenes.get_active_camera();

            var x = m_mouse.get_coords_x(e);
            var y = m_mouse.get_coords_y(e);

            if (x >= 0 && y >= 0) {
                x -= _obj_delta_xy[0];
                y -= _obj_delta_xy[1];

                // emit ray from the camera
                var camera_ray = m_cam.calc_ray(cam, x, y, _vec3_tmp);

                // calculate ray/floor_plane intersection point
                var cam_trans = m_trans.get_translation(cam, _vec3_tmp2);
                var point = m_util.line_plane_intersect(FLOOR_PLANE_NORMAL, 0,
                        cam_trans, camera_ray, _vec3_tmp3);

                // do not process the parallel case and intersections behind the camera
                if (point && camera_ray[1] < 0) {
                    var obj_parent = m_cons.get_parent(_selected_obj);
                    if (obj_parent && m_util.is_armature(obj_parent))
                        // translate the parent (armature) of the animated object
                        m_trans.set_translation_v(obj_parent, point);
                    else
                        m_trans.set_translation_v(_selected_obj, point);
                    limit_object_position(_selected_obj);
                }
            }
        }
}
開發者ID:nil84,項目名稱:b4w-typescript-define,代碼行數:40,代碼來源:main.ts

示例5: main_canvas_down

function main_canvas_down(e) {
    _drag_mode = true;

    if (e.preventDefault)
        e.preventDefault();

    var x = m_mouse.get_coords_x(e);
    var y = m_mouse.get_coords_y(e);

    var obj = m_scenes.pick_object(x, y);

    // handling outline effect
    if (_selected_obj != obj) {
        if (_selected_obj)
            m_scenes.clear_outline_anim(_selected_obj);
        if (obj)
            m_scenes.apply_outline_anim(obj, 1, 1, 0);

        _selected_obj = obj;
    }

    // calculate delta in viewport coordinates
    if (_selected_obj) {
        var cam = m_scenes.get_active_camera();

        var obj_parent = m_cons.get_parent(_selected_obj);
        if (obj_parent && m_util.is_armature(obj_parent))
            // get translation from the parent (armature) of the animated object
            m_trans.get_translation(obj_parent, _vec3_tmp);
        else
            m_trans.get_translation(_selected_obj, _vec3_tmp);
        m_cam.project_point(cam, _vec3_tmp, _obj_delta_xy);

        _obj_delta_xy[0] = x - _obj_delta_xy[0];
        _obj_delta_xy[1] = y - _obj_delta_xy[1];
    }
}
開發者ID:nil84,項目名稱:b4w-typescript-define,代碼行數:37,代碼來源:main.ts


注:本文中的util.is_armature函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。