Javascript 为什么这个babylon.js OnPickTrigger只运行一次?

Javascript 为什么这个babylon.js OnPickTrigger只运行一次?,javascript,3d,babylonjs,Javascript,3d,Babylonjs,我让网格旋转并改变颜色。但是,除非我刷新页面,否则这只能工作一次。我想它旋转和改变颜色,每次点击它。我不知怎的以为这是默认行为。我如何做到这一点 链接到 我在巴比伦论坛上问了同样的问题,并得到了帮助。问题是触发器的值保持不变,因此没有新的插值 可以这样更新值: sphere.actionManager.registerAction( new BABYLON.InterpolateValueAction( BABYLON.ActionManager.

我让网格旋转并改变颜色。但是,除非我刷新页面,否则这只能工作一次。我想它旋转和改变颜色,每次点击它。我不知怎的以为这是默认行为。我如何做到这一点

链接到


我在巴比伦论坛上问了同样的问题,并得到了帮助。问题是触发器的值保持不变,因此没有新的插值

可以这样更新值:

    sphere.actionManager.registerAction(
        new BABYLON.InterpolateValueAction(
            BABYLON.ActionManager.OnPickTrigger,
            light,
            'diffuse',
            BABYLON.Color3.Random(),
            1000,
            undefined,
            undefined,
            function(){
                this.value = BABYLON.Color3.Random();
            }
        )
    );

    sphere.actionManager.registerAction(
        new BABYLON.InterpolateValueAction(
            BABYLON.ActionManager.OnPickTrigger,
            sphere,
            'rotation',
            new BABYLON.Vector3(Math.PI*10, Math.PI*10, Math.PI*10),
            1000,
            undefined,
            undefined,
            function(){
                this.value.addInPlaceFromFloats(Math.PI*10, Math.PI*10, Math.PI*10);
            }
        )
    );
    sphere.actionManager.registerAction(
        new BABYLON.InterpolateValueAction(
            BABYLON.ActionManager.OnPickTrigger,
            light,
            'diffuse',
            BABYLON.Color3.Random(),
            1000,
            undefined,
            undefined,
            function(){
                this.value = BABYLON.Color3.Random();
            }
        )
    );

    sphere.actionManager.registerAction(
        new BABYLON.InterpolateValueAction(
            BABYLON.ActionManager.OnPickTrigger,
            sphere,
            'rotation',
            new BABYLON.Vector3(Math.PI*10, Math.PI*10, Math.PI*10),
            1000,
            undefined,
            undefined,
            function(){
                this.value.addInPlaceFromFloats(Math.PI*10, Math.PI*10, Math.PI*10);
            }
        )
    );