<commit_before>if (typeof user === 'undefined') user = "highfidelity/";
if (typeof repository === 'undefined') repository = "hifi_tests/";
if (typeof branch === 'undefined') branch = "master/";

var autoTester = Script.require("https://github.com/" + user + repository + "blob/" + branch + "tests/utils/autoTester.js?raw=true" );

autoTester.perform("Apply Material Entities to Avatars", Script.resolvePath("."), "primary", function(testType) {
    Script.include("../../../../../utils/test_stage.js?raw=true");

    // Add the test Cases
	var flags = { 
		hasAmbientLight: false
	};
    var createdEntities = setupStage(flags)

    var posOri = getStagePosOriAt(0, 0, 0);

    MyAvatar.orientation = Quat.fromVec3Degrees({x:0, y:180, z:0});

    var LIFETIME = 120;

    createdEntities.push(Entities.addEntity({
        type: "Material",
        materialURL: "materialData",
        position: MyAvatar.position,
        materialData: JSON.stringify({ "materials": {
            "albedo": [0, 0, 1]
        }}),
        lifetime: LIFETIME,
        priority: 1,
        parentMaterialName: 2,
        parentID: MyAvatar.SELF_ID
    }, true));

    var previousSkeletonURL;
    var previousScale;
    var bool previousAvatarVisibility;
    
    autoTester.addStep("Setup avatar", function () {
        // Use a specific avatar.  This is needed because we want the avatar's height to be fixed.
        previousSkeletonURL = MyAvatar.skeletonModelURL;
        MyAvatar.skeletonModelURL = "https://highfidelity.com/api/v1/commerce/entity_edition/813addb9-b985-49c8-9912-36fdbb57e04a.fst?certificate_id=MEUCIQDgYR2%2BOrCh5HXeHCm%2BkR0a2JniEO%2BY4y9tbApxCAPo4wIgXZEQdI4cQc%2FstAcr9tFT9k4k%2Fbuj3ufB1aB4W0tjIJc%3D";

        previousScale = MyAvatar.scale;
        MyAvatar.scale = 1.0;

        // Wait for skeleton to load (for now - only in test mode)
        if (typeof Test !== 'undefined') {
            Test.waitIdle();
        }

        // Set Avatar to T-pose
        for (var i = 0; i < MyAvatar.getJointNames().length; ++i) {
            MyAvatar.setJointData(i, MyAvatar.getDefaultJointRotation(i), MyAvatar.getDefaultJointTranslation(i));
        }

        Camera.mode = "first person";
    });    

    autoTester.addStep("Setup avatar, and make sure it is visible", function () {
        Camera.mode = "mirror";

        previousAvatarVisibility = MyAvatar.getEnableMeshVisible();
        MyAvatar.setEnableMeshVisible(true);
    });    

    autoTester.addStepSnapshot("Avatar without material");
    
    autoTester.addStep("Add material to avatar", function () {
        createdEntities.push(Entities.addEntity({
            type: "Material",
            materialURL: "materialData",
            position: MyAvatar.position,
            materialData: JSON.stringify({ "materials": {
            "albedo": [0, 0, 1]
            }}),
            lifetime: LIFETIME,
            priority: 1,
            parentMaterialName: 0,
            parentID: MyAvatar.SELF_ID
            }, true)
        );    
    });
    
    autoTester.addStepSnapshot("Display material on avatar");

    autoTester.addStep("Clean up after test", function () {
        for (var i = 0; i < createdEntities.length; i++) {
            Entities.deleteEntity(createdEntities[i]);
        }

        // Restore avatar and camera mode
        MyAvatar.skeletonModelURL = previousSkeletonURL;
        MyAvatar.scale = previousScale;
        MyAvatar.clearJointsData();

        MyAvatar.setEnableMeshVisible(previousAvatarVisibility);
    });
    
    var result = autoTester.runTest(testType);
});<commit_msg>Fixed bug.<commit_after>if (typeof user === 'undefined') user = "highfidelity/";
if (typeof repository === 'undefined') repository = "hifi_tests/";
if (typeof branch === 'undefined') branch = "master/";

var autoTester = Script.require("https://github.com/" + user + repository + "blob/" + branch + "tests/utils/autoTester.js?raw=true" );

autoTester.perform("Apply Material Entities to Avatars", Script.resolvePath("."), "primary", function(testType) {
    Script.include("../../../../../utils/test_stage.js?raw=true");

    // Add the test Cases
    var flags = { 
        hasAmbientLight: false
    };
    var createdEntities = setupStage(flags)

    var posOri = getStagePosOriAt(0, 0, 0);

    MyAvatar.orientation = Quat.fromVec3Degrees({x:0, y:180, z:0});

    var LIFETIME = 120;

    createdEntities.push(Entities.addEntity({
        type: "Material",
        materialURL: "materialData",
        position: MyAvatar.position,
        materialData: JSON.stringify({ "materials": {
            "albedo": [0, 0, 1]
        }}),
        lifetime: LIFETIME,
        priority: 1,
        parentMaterialName: 2,
        parentID: MyAvatar.SELF_ID
    }, true));

    var previousSkeletonURL;
    var previousScale;
    var previousAvatarVisibility;

    autoTester.addStep("Setup avatar", function () {
        // Use a specific avatar.  This is needed because we want the avatar's height to be fixed.
        previousSkeletonURL = MyAvatar.skeletonModelURL;
        MyAvatar.skeletonModelURL = "https://highfidelity.com/api/v1/commerce/entity_edition/813addb9-b985-49c8-9912-36fdbb57e04a.fst?certificate_id=MEUCIQDgYR2%2BOrCh5HXeHCm%2BkR0a2JniEO%2BY4y9tbApxCAPo4wIgXZEQdI4cQc%2FstAcr9tFT9k4k%2Fbuj3ufB1aB4W0tjIJc%3D";

        previousScale = MyAvatar.scale;
        MyAvatar.scale = 1.0;

        // Wait for skeleton to load (for now - only in test mode)
        if (typeof Test !== 'undefined') {
            Test.waitIdle();
        }

        // Set Avatar to T-pose
        for (var i = 0; i < MyAvatar.getJointNames().length; ++i) {
            MyAvatar.setJointData(i, MyAvatar.getDefaultJointRotation(i), MyAvatar.getDefaultJointTranslation(i));
        }

        Camera.mode = "first person";
    });    

    autoTester.addStep("Setup avatar, and make sure it is visible", function () {
        Camera.mode = "mirror";

        previousAvatarVisibility = MyAvatar.getEnableMeshVisible();
        MyAvatar.setEnableMeshVisible(true);
    });

    autoTester.addStepSnapshot("Avatar without material");
    
    autoTester.addStep("Add material to avatar", function () {
        createdEntities.push(Entities.addEntity({
            type: "Material",
            materialURL: "materialData",
            position: MyAvatar.position,
            materialData: JSON.stringify({ "materials": {
            "albedo": [0, 0, 1]
            }}),
            lifetime: LIFETIME,
            priority: 1,
            parentMaterialName: 0,
            parentID: MyAvatar.SELF_ID
            }, true)
        );    
    });
    
    autoTester.addStepSnapshot("Display material on avatar");

    autoTester.addStep("Clean up after test", function () {
        for (var i = 0; i < createdEntities.length; i++) {
            Entities.deleteEntity(createdEntities[i]);
        }

        // Restore avatar and camera mode
        MyAvatar.skeletonModelURL = previousSkeletonURL;
        MyAvatar.scale = previousScale;
        MyAvatar.clearJointsData();

        MyAvatar.setEnableMeshVisible(previousAvatarVisibility);
    });

    var result = autoTester.runTest(testType);
});
{'fraction_non_alphanumeric': 0.12426778242677824, 'fraction_numerical': 0.01896792189679219, 'mean_word_length': 2.658673469387755, 'pattern_counts': {'":': 8, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 4, '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': '3013336', 'n_tokens_mistral': 2355, 'n_tokens_neox': 2231, 'n_words': 448}