0
clickイベントを使用して、シーンで既に作成された球のテクスチャを変更しようとしています。シーンには、テキストやcolladaオブジェクトなどの要素もあります。クリック時にテクスチャを変更すると、他のオブジェクトが非表示になる
私は球のテクスチャを変更しますが、シーン内の要素の順序を変更して他の可視オブジェクトを球の背後に隠すようにしています。球の不透明度を変更すると、それ以外の要素がはっきりとわかります。
テクスチャを変更したときに、シーン内の要素の順序を保持するにはどうすればよいですか?
$("#button").click(function(){
var textureLoader = new THREE.TextureLoader(manager);
var materials = [
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.left), transparent: true, opacity: 1}), // right
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.right), transparent: true, opacity: 1}), // left
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.top), transparent: true, opacity: 1}), // top
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.bottom), transparent: true, opacity: 1}), // bottom
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.back), transparent: true, opacity: 1}), // back
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.front), transparent: true, opacity: 1}) // front
];
mesh.material = new THREE.MultiMaterial(materials);
});
スフィア:
var mesh;
var geometry;
var scene = new THREE.Scene();
function init() {
geometry = new THREE.SphereBufferGeometry(500, 60, 40);
geometry.scale(-1, 1, 1);
var textureLoader = new THREE.TextureLoader(manager);
var materials = [
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.left)}), // right
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.right)}), // left
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.top)}), // top
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.bottom)}), // bottom
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.back)}), // back
new THREE.MeshBasicMaterial({map: textureLoader.load(options.cubic.file.front)}) // front
];
mesh = new THREE.Mesh(new THREE.BoxGeometry(1000, 1000, 1000, 7, 7, 7), new THREE.MultiMaterial(materials));
mesh.scale.x = -1;
scene.add(mesh);
}
はい、それは本当にあったからです!また、私は各素材の透明度を偽に変更しなければならなかった – SNos