wangqiujuan0808 2023-12-09 00:53:51 +08:00
parent c61eb163e0
commit 71f00363bd
1 changed files with 8 additions and 8 deletions

View File

@ -84,10 +84,10 @@ onMounted(() => {
}); });
const init = () => { const init = () => {
scene = new THREE.Scene("#00ffff"); scene = new THREE.Scene("#00ffff");
// const texture = new THREE.TextureLoader().load(homeIcon); const texture = new THREE.TextureLoader().load(homeIcon);
// texture.mapping = THREE.EquirectangularReflectionMapping; texture.mapping = THREE.EquirectangularReflectionMapping;
// scene.background = texture scene.background = texture
// scene.environment = texture scene.environment = texture
const canvas = document.querySelector("#three"); const canvas = document.querySelector("#three");
var cubeLoader = new THREE.CubeTextureLoader(); var cubeLoader = new THREE.CubeTextureLoader();
@ -176,6 +176,10 @@ let selectedObject = null;
let selectedMaterial = null; let selectedMaterial = null;
const onMouseDown = (event) => { const onMouseDown = (event) => {
//
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
var raycaster = new THREE.Raycaster() var raycaster = new THREE.Raycaster()
// //
if (selectedObject && selectedMaterial) { if (selectedObject && selectedMaterial) {
@ -183,10 +187,6 @@ const onMouseDown = (event) => {
selectedObject = null; selectedObject = null;
selectedMaterial = null; selectedMaterial = null;
} }
//
mouse.x = (event.clientX / window.innerWidth) * 2 - 1;
mouse.y = -(event.clientY / window.innerHeight) * 2 + 1;
// 线 // 线
raycaster.setFromCamera(mouse, camera); raycaster.setFromCamera(mouse, camera);
// 线 // 线