ThreeJS& TweenJS导致?无关?关于材料不透明度访问的警告#8142

时间:2016-02-15 13:47:41

标签: javascript warnings opacity

我试图概述我们遇到的问题,它只是与控制台充满了围绕.wrapAround和.wrapRGB的警告,试图使用TweenJS来访问材料的不透明度。 警告只显示一次然而我们循环一系列对象并将补间应用于它们,所以我们最终得到了一个非常烦人的泛滥控制台日志。也许我们做错了什么,并且有一个简单的解决方法可以停止看到这些警告,但我无法解决这个问题,我希望你可以提供帮助吗? :)

以下是基本示例的代码:

//SCENE
scene = new THREE.Scene();
scene.fog = new THREE.FogExp2( 0x000000, 0.011, 0.08 );

//RENDERER
renderer.setClearColor( 0x000000, 0 );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( 800, 600 );

//CAMERA
camera = new THREE.PerspectiveCamera( 60, 800 / 600, 1, 30000 );
camera.position.x = 5;
camera.position.y = 10;
camera.position.z = 5;
camera.lookAt(new THREE.Vector3());

//LIGHTS
// Create Lights and add them to the scene
var ambient = new THREE.AmbientLight(0xffffff);
scene.add(ambient);

var directionalLight = new THREE.DirectionalLight(0x999999, 2.1);
directionalLight.position.set(0, 10, 10).normalize();
scene.add(directionalLight);

//SETUP SCENE
var geometry = new THREE.PlaneGeometry(10,10,1,1);
var material = new THREE.MeshBasicMaterial({color:0xff0000, opacity:1, transparent:true, shading: THREE.SmoothShading});
mesh = new THREE.Mesh(geometry, material);
mesh.rotation.x = THREE.Math.degToRad(-90);
scene.add(mesh);

/**
*   This way causes no warnings!
*/
/*
var opacity = mesh.material.opacity;
new TWEEN.Tween(opacity)
        .to({opacity:0}, 2000)
        .delay(10)
        .onUpdate(function(){
            mesh.material.needsUpdating = true;
            mesh.material.opacity-=0.01;
        })
        .yoyo(true)
        .repeat(Infinity)
        .start();
*/


/**
*   This way causes warnings!
*/
new TWEEN.Tween(mesh.material)
        .to({opacity:0}, 2000)
        .delay(10)
        .onUpdate(function(){
            mesh.material.needsUpdating = true;
        })
        .yoyo(true)
        .repeat(Infinity)
        .start();
loop();

因此,如果您看到第二个补间,我在其中访问mesh.material并尝试补间不透明度,我似乎得到两个与不透明度无关的警告....

THREE.MeshBasicMaterial:.wrapAround已被删除。 -three.min.js:387 THREE.MeshBasicMaterial:.wrapRGB已被删除。 -three.min.js:387

这是使用r73,但我相信这个问题在r74中仍然存在。

有没有办法看不到这些警告,因为我说我们在一个对象数组中应用了一个类似的补间,因此会重复显示这些警告,所以我们的控制台会发出警告。

无论如何都有帮助吗?

1 个答案:

答案 0 :(得分:0)

嗯,我添加了一个示例页面,无论如何要看看..... http://polygonprophecy.com/html5/wrapAroundTest/只需检查控制台,看到在使用带有ThreeJ的TweenJS查看代码时只是检查iframe的警告泛滥,谢谢!