<commit_before>module wd{
    export class Shadow extends Component {
        public static create() {
            var obj = new this();

            return obj;
        }

        private _receive:boolean = true;
        @cloneAttributeAsBasicType()
        get receive() {
            return this._receive;
        }

        set receive(receive:boolean) {
            this._receive = receive;
        }

        private _cast:boolean = true;
        @cloneAttributeAsBasicType()
        get cast() {
            return this._cast;
        }

        set cast(cast:boolean) {
            this._cast = cast;
        }

        public entityObject:GameObject;

        private _layer:string = <any>EShadowLayer.DEFAULT;
        @cloneAttributeAsBasicType()
        get layer(){
            if(InstanceUtils.isObjectInstance(this.entityObject) && !InstanceUtils.isHardwareSupport()){
                this._layer = this.entityObject.getComponent<ObjectInstance>(ObjectInstance).sourceObject.getComponent<Shadow>(Shadow).layer;
            }

            return this._layer;
        }
        set layer(layer:string){
            if(layer && this._layer !== layer){
                this._layer = layer;
            }
        }

        private _shadowMapLayerChangeSubscription:wdFrp.IDisposable = null;

        @require(function (entityObject:EntityObject, isShareComponent:boolean = false) {
            assert(entityObject instanceof GameObject, Log.info.FUNC_SHOULD("add to GameObject"));
        })
        public addToObject(entityObject:EntityObject, isShareComponent:boolean = false) {
            super.addToObject(entityObject, isShareComponent);
        }

        public clone() {
            return CloneHelper.clone(this);
        }

        public init() {
            var self = this;

            if(InstanceUtils.isObjectInstance(this.entityObject)
                || !this._isFirstLevelObjectOfSceneOrSpacePartition()){
                return;
            }

            if (this.receive) {
                this._handleReceive();
            }

            this._shadowMapLayerChangeSubscription = EventManager.fromEvent(<any>EEngineEvent.SHADOWMAP_LAYER_CHANGE)
                .subscribe(() => {
                    if (self.receive) {
                        self._handleReceive();
                    }
                });
        }

        public dispose(){
            //todo test
            this._shadowMapLayerChangeSubscription && this._shadowMapLayerChangeSubscription.dispose();
        }

        //public update(elapsedTime:number){
        //    if(Director.getInstance().scene.shadowLayerList.dirty){
        //        this._updateWhenShadowLayerChange();
        //
        //        this.entityObject.shadowLayerList.dirty = false;
        //    }
        //}

        private _addAllShadowMaps(twoDShadowMapDataMap:wdCb.Hash<wdCb.Collection<TwoDShadowMapData>>, cubemapShadowMapDataMap:wdCb.Hash<wdCb.Collection<CubemapShadowMapData>>, mapManager:MapManager){
            twoDShadowMapDataMap.forEach((twoDShadowMapDataList:wdCb.Collection<TwoDShadowMapData>) => {
                twoDShadowMapDataList.forEach(({shadowMap}) => {
                    //if (!mapManager.hasTwoDShadowMap(shadowMap)) {
                        mapManager.addTwoDShadowMap(shadowMap);
                    //}
                });
            });

            cubemapShadowMapDataMap.forEach((cubemapShadowMapDataList:wdCb.Collection<CubemapShadowMapData>) => {
                cubemapShadowMapDataList.forEach(({shadowMap}) => {
                    //if (!mapManager.hasCubemapShadowMap(shadowMap)) {
                        mapManager.addCubemapShadowMap(shadowMap);
                    //}
                });
            });
        }

        private _isFirstLevelObjectOfSceneOrSpacePartition(){
            var parent:GameObject = this.entityObject.parent;

            return JudgeUtils.isEqual(parent, Director.getInstance().scene) || JudgeUtils.isSpacePartitionObject(parent);
        }

        private _handleReceive(){
            var self = this,
                twoDShadowMapDataMap:wdCb.Hash<wdCb.Collection<TwoDShadowMapData>> = Director.getInstance().scene.gameObjectScene.getComponent(ShadowManager).twoDShadowMapDataMap,
                cubemapShadowMapDataMap:wdCb.Hash<wdCb.Collection<CubemapShadowMapData>> = Director.getInstance().scene.gameObjectScene.getComponent(ShadowManager).cubemapShadowMapDataMap;
            var handle = (gameObject:GameObject) => {
                if (!gameObject.hasComponent(Geometry)) {
                    return;
                }

                let material:Material = gameObject.getComponent<Geometry>(Geometry).material,
                    mapManager:MapManager = material.mapManager;

                //material.shader.definitionDataDirty = true;

                material.shader.libDirty = true;

                mapManager.removeAllShdaowMaps();

                self._addAllShadowMaps(twoDShadowMapDataMap, cubemapShadowMapDataMap, mapManager);

                gameObject.forEach((child:GameObject) => {
                    handle(child);<commit_msg>pass pointShadowMapSpec->first level object has no geometry but its children has geometry, its children should be involved in shadow unit test<commit_after>module wd{
    export class Shadow extends Component {
        public static create() {
            var obj = new this();

            return obj;
        }

        private _receive:boolean = true;
        @cloneAttributeAsBasicType()
        get receive() {
            return this._receive;
        }

        set receive(receive:boolean) {
            this._receive = receive;
        }

        private _cast:boolean = true;
        @cloneAttributeAsBasicType()
        get cast() {
            return this._cast;
        }

        set cast(cast:boolean) {
            this._cast = cast;
        }

        public entityObject:GameObject;

        private _layer:string = <any>EShadowLayer.DEFAULT;
        @cloneAttributeAsBasicType()
        get layer(){
            if(InstanceUtils.isObjectInstance(this.entityObject) && !InstanceUtils.isHardwareSupport()){
                this._layer = this.entityObject.getComponent<ObjectInstance>(ObjectInstance).sourceObject.getComponent<Shadow>(Shadow).layer;
            }

            return this._layer;
        }
        set layer(layer:string){
            if(layer && this._layer !== layer){
                this._layer = layer;
            }
        }

        private _shadowMapLayerChangeSubscription:wdFrp.IDisposable = null;

        @require(function (entityObject:EntityObject, isShareComponent:boolean = false) {
            assert(entityObject instanceof GameObject, Log.info.FUNC_SHOULD("add to GameObject"));
        })
        public addToObject(entityObject:EntityObject, isShareComponent:boolean = false) {
            super.addToObject(entityObject, isShareComponent);
        }

        public clone() {
            return CloneHelper.clone(this);
        }

        public init() {
            var self = this;

            if(InstanceUtils.isObjectInstance(this.entityObject)
                || !this._isFirstLevelObjectOfSceneOrSpacePartition()){
                return;
            }

            if (this.receive) {
                this._handleReceive();
            }

            this._shadowMapLayerChangeSubscription = EventManager.fromEvent(<any>EEngineEvent.SHADOWMAP_LAYER_CHANGE)
                .subscribe(() => {
                    if (self.receive) {
                        self._handleReceive();
                    }
                });
        }

        public dispose(){
            //todo test
            this._shadowMapLayerChangeSubscription && this._shadowMapLayerChangeSubscription.dispose();
        }

        //public update(elapsedTime:number){
        //    if(Director.getInstance().scene.shadowLayerList.dirty){
        //        this._updateWhenShadowLayerChange();
        //
        //        this.entityObject.shadowLayerList.dirty = false;
        //    }
        //}

        private _addAllShadowMaps(twoDShadowMapDataMap:wdCb.Hash<wdCb.Collection<TwoDShadowMapData>>, cubemapShadowMapDataMap:wdCb.Hash<wdCb.Collection<CubemapShadowMapData>>, mapManager:MapManager){
            twoDShadowMapDataMap.forEach((twoDShadowMapDataList:wdCb.Collection<TwoDShadowMapData>) => {
                twoDShadowMapDataList.forEach(({shadowMap}) => {
                    //if (!mapManager.hasTwoDShadowMap(shadowMap)) {
                        mapManager.addTwoDShadowMap(shadowMap);
                    //}
                });
            });

            cubemapShadowMapDataMap.forEach((cubemapShadowMapDataList:wdCb.Collection<CubemapShadowMapData>) => {
                cubemapShadowMapDataList.forEach(({shadowMap}) => {
                    //if (!mapManager.hasCubemapShadowMap(shadowMap)) {
                        mapManager.addCubemapShadowMap(shadowMap);
                    //}
                });
            });
        }

        private _isFirstLevelObjectOfSceneOrSpacePartition(){
            var parent:GameObject = this.entityObject.parent;

            return JudgeUtils.isEqual(parent, Director.getInstance().scene) || JudgeUtils.isSpacePartitionObject(parent);
        }

        private _handleReceive(){
            var self = this,
                twoDShadowMapDataMap:wdCb.Hash<wdCb.Collection<TwoDShadowMapData>> = Director.getInstance().scene.gameObjectScene.getComponent(ShadowManager).twoDShadowMapDataMap,
                cubemapShadowMapDataMap:wdCb.Hash<wdCb.Collection<CubemapShadowMapData>> = Director.getInstance().scene.gameObjectScene.getComponent(ShadowManager).cubemapShadowMapDataMap;
            var handle = (gameObject:GameObject) => {
                if (gameObject.hasComponent(Geometry)) {
                    let material:Material = gameObject.getComponent<Geometry>(Geometry).material,
                        mapManager:MapManager = material.mapManager;

                    material.shader.libDirty = true;

                    mapManager.removeAllShdaowMaps();

                    self._addAllShadowMaps(twoDShadowMapDataMap, cubemapShadowMapDataMap, mapManager);

                }

                gameObject.forEach((child:GameObject) => {
                    handle(child);
{'fraction_non_alphanumeric': 0.09700552379106503, 'fraction_numerical': 0.0, 'mean_word_length': 1.995645863570392, 'pattern_counts': {'":': 0, '<': 33, '<?xml version=': 0, '>': 48, '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': '1054090', 'n_tokens_mistral': 2706, 'n_tokens_neox': 2577, 'n_words': 348}