当前位置: 首页>>代码示例>>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;未经允许,请勿转载。