所以我的控制台上有这个警告。我阅读了文档:https://developers.google.com/web/updates/2017/09/autoplay-policy-changes
我按照他们说的做了一切,但我仍然有这个警告。这是我的代码:
let context;
window.onload = function() {
context = new AudioContext();
...
}
// click event
document.addEventListener('click', function (e) {
if (e.target.closest('.play1')) {
context.resume().then(() => {
source.start(0);
});
}
})
Run Code Online (Sandbox Code Playgroud)
警告文本是关于这一行的:context = new AudioContext();
有人看到我缺少什么吗?非常感谢
我想在动画过程中修改相机的 FOV 值。不幸的是,一旦我实现了 FOV 值,我就可以观察到我的场景变得更小。
所以我一直想知道,FOV 值和透视相机的距离位置之间的数学联系是什么?
这个想法是在 FOV 值发生变化时拥有相同的场景(通过修改相机位置来实现相同的大小)。
非常感谢。
编辑1:
这是说明我的问题的片段:当我实现相机的 FOV 值(从 4 到 45)时,我的方块和相机之间的距离发生了变化。我该如何预防呢?
let W = window.innerWidth, H = window.innerHeight;
let renderer = new THREE.WebGLRenderer( { antialias: true, alpha: true } );
renderer.setPixelRatio( window.devicePixelRatio );
renderer.setSize( W, H );
document.body.appendChild( renderer.domElement );
let camera = new THREE.PerspectiveCamera( 4, W/H, 1, 100 );
let scene = new THREE.Scene();
camera.position.set(0,0,14);
camera.lookAt(0,0,0);
let geo = new THREE.BoxGeometry(0.5, 0.5, 0.5);
let mat = new THREE.MeshNormalMaterial();
let mesh = new …Run Code Online (Sandbox Code Playgroud)我的场景中有两个网格。中间有一个圆柱体和一架经典飞机。我在圆柱体上应用了 png 纹理,这样我们就可以看穿。它似乎适用于气缸。
在此屏幕截图中,您可以轻松地看到我的问题:我不明白为什么我的图像在圆柱体后面不可见。
我用于气缸的代码:
myCylinderMesh.material.transparent = true;
myCylinderMesh.material.side = THREE.DoubleSide;
Run Code Online (Sandbox Code Playgroud)
我怎样才能看到隐藏在圆柱体后面的图像部分?
编辑1:
我添加了 @ScieCode 发送给我的代码:
myCylinderMesh.material.alphaTest = 0.5;
Run Code Online (Sandbox Code Playgroud)
它效果更好:现在我可以看到图像中缺失的部分。但缺少一件事:我的圆柱体的不透明度。我应该也能看到字母背后我的形象。目前我有这样的不透明度:
myCylinderMesh.material.opacity = 0.7;
Run Code Online (Sandbox Code Playgroud)
你知道我错过了什么吗?谢谢
编辑2:
这是我的两个网格的代码:
圆柱 :
geoCylinder = new THREE.CylinderBufferGeometry( 0.4, 0.4, 2*Math.PI*0.4/(2048/128), 64, 1, true );
matCylinder = new THREE.MeshBasicMaterial( { map:texture, transparent:true, color:0x000000, alphaTest: 0.5, opacity: 0.6, side: THREE.DoubleSide } );
meshCylinder = new THREE.Mesh( geoCylinder, matCylinder );
Run Code Online (Sandbox Code Playgroud)
飞机 :
geoPlane = new THREE.PlaneBufferGeometry( 0.8, 0.8 );
matPlane = new THREE.MeshBasicMaterial( { map: texturePlane, transparent:true} …Run Code Online (Sandbox Code Playgroud) 我想知道如何使用 Three.js 在鼠标区域周围应用着色器效果就像在本网站的主页:https ://activetheory.net/
我很想找到一些线索或例子。非常感谢