123
parent
c61eb163e0
commit
71f00363bd
|
@ -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);
|
||||||
// 计算射线和场景中所有可点击物体的相交情况
|
// 计算射线和场景中所有可点击物体的相交情况
|
||||||
|
|
Loading…
Reference in New Issue